![](https://img-blog.csdnimg.cn/20201014180756928.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
LeetCode
_iorilan
10年以上软件工程经验,先后从事在线教育/IT金融/即时通信/政府/物流平台/零售/门禁/监控等领域。专注夯实基础/项目成本与架构平衡/框架调研/团队高效协同工作
展开
-
LeetCode -- Best Time to Buy and Sell Stock II
题目描述:Say you have an array for which the ith element is the price of a given stock on day i.Design an algorithm to find the maximum profit. You may complete as many transactions as you like (ie, buy o原创 2015-08-23 16:08:56 · 921 阅读 · 0 评论 -
Contains Duplicate III
题目描述:Given an array of integers, find out whether there are two distinct indices i and j in the array such that the difference between nums[i] and nums[j] is at most t and the difference between i and原创 2015-08-23 16:20:29 · 1173 阅读 · 0 评论 -
LeetCode --- Count And Say
题目概述 :遍历字符串,先数,遇到相邻相同则++count,否则累加字符串。对于1 : 1个1 : "11"11 : "2个1" : "21"21 : "1个2 1个1": "1211" ...问题: 求第n项实现思路:外循环0...n,从第一项开始求,一直求到n遍历字符串str。count初始化为1,str2为空。判断相邻字符是否相等(注意处理末尾字符的情况),相等则++count,否则str2原创 2015-07-23 09:27:05 · 1400 阅读 · 1 评论 -
LeetCode -- Candy
LeetCode -- Candy原创 2015-08-25 16:11:53 · 1055 阅读 · 0 评论 -
Leet -- Plus One
Leet -- Plus One原创 2015-08-25 16:53:33 · 994 阅读 · 0 评论 -
LeetCode -- 删除链表中值为k的元素
本题目比较直接,一次遍历遇到匹配的元素直接删除(通过n.next = n.next.next)就可以了,只是需要考虑到:1.首节点的情况2.末节点的情况以下为实现:public ListNode RemoveElements(ListNode head, int val) { // null list if(head == null){ return null; } /原创 2015-07-23 09:17:01 · 1579 阅读 · 0 评论 -
LeetCode -- Flatten 二叉树
LeetCode -- Flatten 二叉树原创 2015-08-11 15:25:12 · 1140 阅读 · 0 评论 -
LeetCode -- Path Sum ||
LeetCode -- Path Sum ||原创 2015-08-11 18:09:14 · 1116 阅读 · 0 评论 -
LeetCode -- 顺时针旋转图片90度
LeetCode -- 顺时针旋转图片90度原创 2015-08-11 17:47:05 · 2379 阅读 · 0 评论 -
LeetCode -- 反转英文单词
问题:给定英文句子,反转里面的每个单词,例如"the sky is blue" 反转后为 "blue is the sky"实现思路:对英文句子每个字符做循环s存放反转的句子,w存放单词遇到空格(1个或多个)将w添加到s中非空格则将字符添加到w实现代码:var reverseWords = function(str) { str = str.trim(); var s = "";原创 2015-07-23 11:27:49 · 2611 阅读 · 0 评论 -
LeetCode -- 查找最小公共祖先
LeetCode -- 查找最小公共祖先原创 2015-08-11 15:29:55 · 3025 阅读 · 0 评论 -
LeetCode 格雷码序列的生成
LeetCode 格雷码序列的生成原创 2015-07-23 11:22:14 · 2302 阅读 · 0 评论 -
Leet -- Generate Parentheses
Leet -- Generate Parentheses原创 2015-08-27 15:20:33 · 1066 阅读 · 0 评论 -
LeetCode -- Distinct Subsequences
LeetCode -- Distinct Subsequences原创 2015-08-29 13:33:19 · 1120 阅读 · 0 评论 -
LeetCode -- Substring with Concatenation of All Words
LeetCode -- Substring with Concatenation of All Words原创 2015-08-14 13:04:42 · 1170 阅读 · 0 评论 -
LeetCode -- 帕斯卡三角形
LeetCode -- 帕斯卡三角形原创 2015-08-03 16:13:50 · 1815 阅读 · 0 评论 -
LeetCode - Merge Intervals
LeetCode - Merge Intervals原创 2015-08-03 16:15:04 · 1076 阅读 · 0 评论 -
LeetCode -- Three Sum
LeetCode -- Three Sum原创 2015-08-03 16:26:49 · 1192 阅读 · 0 评论 -
LeetCode -- Decode Ways
LeetCode -- Decode Ways原创 2015-08-14 12:31:40 · 1080 阅读 · 0 评论 -
LeetCode -- house robber
LeetCode -- house robber原创 2015-07-25 14:39:44 · 1575 阅读 · 3 评论 -
Leet Code -- Unique BST
Leet Code -- Unique BST原创 2015-07-23 12:48:36 · 1229 阅读 · 0 评论 -
LeetCode -- 求字符串数组中的最长公共前缀
LeetCode -- 求字符串数组中的最长公共前缀原创 2015-07-25 14:51:44 · 4452 阅读 · 1 评论 -
LeetCode -- 判断链表中是否有环
LeetCode -- 判断链表中是否有环原创 2015-07-23 19:46:56 · 2315 阅读 · 0 评论 -
LeetCode -- 最大连续乘积子序列
LeetCode -- 最大连续乘积子序列原创 2015-07-23 11:39:03 · 2771 阅读 · 0 评论 -
LeetCode -- WordBreak II
题目描述:Given a string s and a dictionary of words dict, add spaces in s to construct a sentence where each word is a valid dictionary word.Return all such possible sentences.For example, givens = "catsa原创 2015-09-01 15:04:03 · 1592 阅读 · 1 评论 -
LeetCode -- SpiralOrder
题目描述:Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order.For example,Given the following matrix:[ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ]]You should r原创 2015-09-01 13:29:29 · 1598 阅读 · 1 评论 -
LeetCode -- Balanced Binary Tree
题目描述:Given a binary tree, determine if it is height-balanced.For this problem, a height-balanced binary tree is defined as a binary tree in which the depth of the two subtrees of every node never diff原创 2015-09-05 17:40:15 · 1634 阅读 · 0 评论 -
LeetCode -- Count Complete Tree Node
LeetCode -- Count Complete Tree Node原创 2015-09-04 19:18:10 · 1635 阅读 · 0 评论 -
LeetCode -- Insert Interval
LeetCode -- Insert Interval原创 2015-09-25 11:45:29 · 1446 阅读 · 1 评论 -
LeetCode -- Longest Valid Parentheses
LeetCode -- Longest Valid Parentheses原创 2015-09-25 11:47:05 · 1498 阅读 · 0 评论 -
LeetCode -- Isomorphic Strings
LeetCode -- Isomorphic Strings原创 2015-09-05 17:10:49 · 1972 阅读 · 0 评论 -
LeetCode -- Permutations
LeetCode -- Permutations原创 2015-09-25 11:49:21 · 1676 阅读 · 1 评论 -
LeetCode -- Convert SortedList To BST
Convert SortedList To BST原创 2015-09-25 11:43:39 · 1577 阅读 · 0 评论 -
LeetCode -- Merge Two sorted lists
LeetCode -- Merge Two sorted lists原创 2015-09-07 09:50:07 · 1258 阅读 · 0 评论 -
LeetCode -- Binary Tree Zigzag Level Order Traversal
题目描述:Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).For example:Given binary t原创 2015-09-11 21:33:57 · 1307 阅读 · 0 评论 -
LeetCode -- Compare Version Numbers
题目描述:compare two version numbers version1 and version2.If version1 > version2 return 1, if version1 You may assume that the version strings are non-empty and contain only digits and the . character.Th原创 2015-09-11 21:38:10 · 1378 阅读 · 0 评论 -
LeetCode -- Implement Queue using Stacks
LeetCode -- Implement Queue using Stacks原创 2015-09-11 21:40:39 · 1434 阅读 · 0 评论 -
Leet -- Remove Duplicates from Sorted Array
Leet -- Remove Duplicates from Sorted Array原创 2015-08-22 22:43:12 · 1044 阅读 · 0 评论 -
LeetCode -- Longest Substring Without Repeating Characters
题目描述:Given a string, find the length of the longest substring without repeating characters. For example, the longest substring without repeating letters for "abcabcbb" is "abc", which the length is 3.原创 2015-09-13 22:20:01 · 1454 阅读 · 0 评论 -
LeetCode -- Add Digits
题目描述:Given a non-negative integer num, repeatedly add all its digits until the result has only one digit.For example:Given num = 38, the process is like: 3 + 8 = 11, 1 + 1 = 2. Since 2 has only one di原创 2015-09-13 22:44:21 · 1423 阅读 · 0 评论