LeetCode
小森林冬春
这个作者很懒,什么都没留下…
展开
-
LeetCode: 524. Longest Word in Dictionary through Deleting
LeetCode: 524. Longest Word in Dictionary through Deleting题目意思是,给定一个字符串s,一堆字符串d,请找出d中是否存在一个字符串是s中删某些字符串得到的,并找出符合要求的字典序最小的那一个。好的,其实用两个指针,遍历就可以了。(其实严格来说是三个,s一个,d中字符串顺序一个,子字符串内部一个。时间复杂度是O(nm),因为输入本身就是nm了,原创 2017-02-27 21:44:57 · 1173 阅读 · 0 评论 -
Leetcode: 326. Power of Three
Leetcode: 326. Power of Three技巧型题目,做笔试的时候看到了,觉得还有点意思。就写了一下。 题目意思是:判断一个数是不是3的幂。不用递归或者循环。那很明显就考你思路开阔的了。log法第一种方法涉及精度,是说判断log3n是不是整数。因为只有3的幂的数才会得到整数。然后用换底公式换成判断log10n/log103。class Solution {public:原创 2017-04-14 21:32:21 · 333 阅读 · 0 评论 -
Leetcode: 576. Out of Boundary Paths
Leetcode: 576. Out of Boundary Paths这是一个算所有可能的总数的题目。有一个二维数组,其中一格上面放了一个足球,每次可以往四个方向将球移动一格。已知可以移动N步,求问总共有多少种方法可以将足球移出边界。因为可能有太多种可能了,要求对结果进行一个大数取余mod 109 + 7。 一看就是卡复杂度的题目,用递归这样的栈一定会爆掉的。因为题目是DP的嘛,当然是考虑用DP原创 2017-07-03 16:27:27 · 484 阅读 · 0 评论 -
Leetcode: 3. Longest Substring Without Repeating Characters
Leetcode: 3. Longest Substring Without Repeating Characters一道一般的字符串问题,要求在给定字符串中找出不含重复字符的最长子串的长度。思路一个简单的思路是碰到重复的就回到上一个重复的字母的下一位开始找。 int lengthOfLongestSubstring(string s) { // Start typing yo原创 2017-07-03 16:35:24 · 156 阅读 · 0 评论 -
Leetcode: 42. Trapping Rain Water
Leetcode: 42. Trapping Rain Water原创 2017-07-03 16:46:04 · 204 阅读 · 0 评论 -
Leetcode: 128. Longest Consecutive Sequence
Leetcode: 128. Longest Consecutive Sequence求对一个无序序列,求其中排序后最长连续序列,并给定了O(n)复杂度限制。解法既然要O(n)算法,排序显然不行,所以自然想到用hash table。将序列中的所有数存到一个unordered_set中。对于序列里任意一个数A[i],我们可以通过set马上能知道A[i]+1和A[i]-1是否也在序列中。如果在,继续找A原创 2017-07-03 16:50:09 · 219 阅读 · 0 评论 -
Leetcode: 301.Remove Invalid Parentheses
Leetcode: 301.Remove Invalid Parentheses原创 2017-07-04 00:51:34 · 427 阅读 · 0 评论 -
Leetcode: 23.Merge k Sorted Lists
Leetcode: 23.Merge k Sorted Lists原创 2017-07-04 01:01:01 · 322 阅读 · 0 评论 -
Leetcode: 526. Beautiful Arrangement
Leetcode: 526. Beautiful Arrangement原创 2017-06-26 12:21:32 · 328 阅读 · 0 评论 -
Leetcode: House Robber 系列
Leetcode: House Robber 系列这个系列包括以下题目: - 198. House Robber - 213. House Robber II - 337. House Robber III原创 2017-03-31 18:32:19 · 356 阅读 · 0 评论 -
leetcode: Best Time to Buy and Sell Stock 系列
leetcode: Best Time to Buy and Sell Stock 系列一系列包括: - Best Time to Buy and Sell Stock Ⅰ - Best Time to Buy and Sell Stock Ⅱ - Best Time to Buy and Sell Stock Ⅲ - Best Time to Buy and Sell Stock Ⅳ原创 2017-03-30 20:46:47 · 395 阅读 · 0 评论 -
LeetCode: 529. Minesweeper
LeetCode: 529. Minesweeper原创 2017-02-28 12:33:59 · 1231 阅读 · 0 评论 -
Leetcode: 332.Reconstruct Itinerary
Leetcode: 332.Reconstruct Itinerary原创 2017-03-17 17:02:50 · 359 阅读 · 0 评论 -
LeetCode 98. Validate Binary Search Tree
LeetCode 98. Validate Binary Search Tree原创 2017-02-25 20:27:40 · 260 阅读 · 0 评论 -
LeetCode: 503.Minimum Absolute Difference in BST
LeetCode: 503.Minimum Absolute Difference in BST原创 2017-02-26 13:40:35 · 663 阅读 · 0 评论 -
LeetCode: 523. Continuous Subarray Sum
LeetCode: 523. Continuous Subarray Sum原创 2017-02-27 16:50:41 · 735 阅读 · 0 评论 -
Leetcode: 310.Minimum Height Trees
Leetcode: 310.Minimum Height Trees原创 2017-03-12 21:57:01 · 247 阅读 · 0 评论 -
LeetCode: 399. Evaluate Division
LeetCode: 399. Evaluate Division原创 2017-03-11 17:17:31 · 852 阅读 · 0 评论 -
Leetcode: 338.Counting Bits
Leetcode: 338.Counting Bits原创 2017-03-28 20:46:11 · 266 阅读 · 0 评论 -
Leetcode: 477. Total Hamming Distance
Leetcode: 477. Total Hamming Distance原创 2017-06-26 12:53:07 · 272 阅读 · 0 评论