随笔分类 -  lintCode

上一页 1 2 3 4 5 6 下一页

Copy Books
摘要:Note: 这道题很有意思,用的是二分法。想法是不停的试错。这个博客主把这个问题说的很清楚 https://xuezhashuati.blogspot.com/2017/03/lintcode-437-copy-books.html 其实二分法的方法可以变化的点很有限,最多变化的就是检查条件。一般难 阅读全文

posted @ 2017-05-28 03:28 codingEskimo 阅读(291) 评论(0) 推荐(0)

[LintCode] Largest Divisible Subset
摘要:Given a set of distinct positive integers, find the largest subset such that every pair (Si, Sj) of elements in this subset satisfies: Si % Sj = 0 or  阅读全文

posted @ 2017-05-26 12:31 codingEskimo 阅读(154) 评论(0) 推荐(0)

[LintCode] Longest Increasing Subsequence
摘要:Given a sequence of integers, find the longest increasing subsequence (LIS). You code should return the length of the LIS. Given a sequence of integer 阅读全文

posted @ 2017-05-26 11:05 codingEskimo 阅读(108) 评论(0) 推荐(0)

[LintCode] Perfect Squares
摘要:方法一: 动态规划 https://segmentfault.com/a/1190000003768736 https://siddontang.gitbooks.io/leetcode-solution/content/dynamic_programming/perfect_squares.htm 阅读全文

posted @ 2017-05-25 12:15 codingEskimo 阅读(279) 评论(0) 推荐(0)

Sqrt(x) II
摘要:Important Note:1) Pay attention to the number that is less than 1.0, because x^0.5 will larger than x. So we need to always set the right side to be 1 阅读全文

posted @ 2017-05-11 05:27 codingEskimo 阅读(119) 评论(0) 推荐(0)

Maximum Average Subarray
摘要:Important Reference: http://stackoverflow.com/questions/13093602/finding-subarray-with-maximum-sum-number-of-elements http://www.jiuzhang.com/qa/2942/ 阅读全文

posted @ 2017-05-11 04:43 codingEskimo 阅读(115) 评论(0) 推荐(0)

Search a 2D Matrix II
摘要:The reference link: http://www.code123.cc/docs/leetcode-notes/binary_search/search_a_2d_matrix_ii.html 题解 - 自右上而左下 阅读全文

posted @ 2017-05-10 07:02 codingEskimo 阅读(95) 评论(0) 推荐(0)

Divide Two Integers
摘要:This question is very hard, just remember it:Explaination: 思路清晰,就是二倍法。直接用除数去一个一个加,直到被除数被超过的话,会超时。解决办法每次将被除数增加1倍,同时将count也增加一倍,如果超过了被除数,那么用被除数减去当前和再继续本 阅读全文

posted @ 2017-05-09 10:11 codingEskimo 阅读(110) 评论(0) 推荐(0)

K Closest Numbers In Sorted Array
摘要:Important Node: 1) This problem has two parts: a. find the closest number's to the target and return its index. This is standard binary search problem 阅读全文

posted @ 2017-05-09 08:09 codingEskimo 阅读(107) 评论(0) 推荐(0)

Find Minimum in Rotated Sorted Array II
摘要:The worst situation O(N). Actually we can either just loop through, or we can compare num[mid] with the num[end], if they are the same, that means it' 阅读全文

posted @ 2017-05-04 07:58 codingEskimo 阅读(91) 评论(0) 推荐(0)

Search for a Range
摘要:O(logN) This question turns to find the first and last element of the target in a sorted array. Just be careful with the two result coming out of the 阅读全文

posted @ 2017-05-04 07:25 codingEskimo 阅读(92) 评论(0) 推荐(0)

Search in Rotated Sorted Array II
摘要:O(N) if element can repeat, the worst case, you cannot throw away any section. eg. [1, 1, 1, 1, 0, 1, 1] target = 0, you cannot throw any section. We 阅读全文

posted @ 2017-05-04 07:11 codingEskimo 阅读(51) 评论(0) 推荐(0)

Search in Rotated Sorted Array
摘要:O(logN) Important Point: Once the target is in one section, use the point in that section as benchmark In this problem, if the target >= startVal, use 阅读全文

posted @ 2017-05-04 06:55 codingEskimo 阅读(105) 评论(0) 推荐(0)

First Bad Version
摘要:O(logN) 阅读全文

posted @ 2017-05-04 06:21 codingEskimo 阅读(75) 评论(0) 推荐(0)

Find Peak Element
摘要:O(logN) Check four different situations: 1) The peek 2) increasing section 3) decreasing section 4) minimum 阅读全文

posted @ 2017-05-04 06:16 codingEskimo 阅读(84) 评论(0) 推荐(0)

Find Minimum in Rotated Sorted Array
摘要:O(logN) There are two section: 1) increase array which the first element is larger than end one. 2) the minimum to end Comparing with the endVal, 1) i 阅读全文

posted @ 2017-05-04 06:06 codingEskimo 阅读(94) 评论(0) 推荐(0)

Search in a Big Sorted Array
摘要:O(logN) 阅读全文

posted @ 2017-05-04 05:45 codingEskimo 阅读(91) 评论(0) 推荐(0)

Maximum Number in Mountain Sequence
摘要:O(logN) Important Point: if there "mid" exists, it has at laest three elements in "nums", because otherwise it will not come inside the loop. So later 阅读全文

posted @ 2017-05-04 05:28 codingEskimo 阅读(99) 评论(0) 推荐(0)

Sqrt(x)
摘要:class Solution { /** * @param x: An integer * @return: The sqrt of x */ public int sqrt(int x) { // write your code here if (x < 0) { return -1; ... 阅读全文

posted @ 2017-05-02 09:40 codingEskimo 阅读(90) 评论(0) 推荐(0)

Drop Eggs
摘要:If it is two eggs: http://datagenetics.com/blog/july22012/index.html Imagine we drop our first egg from floor n, if it breaks, we can step through the 阅读全文

posted @ 2017-05-02 09:02 codingEskimo 阅读(359) 评论(0) 推荐(0)

上一页 1 2 3 4 5 6 下一页

导航