随笔分类 -  Leetcode

上一页 1 ··· 4 5 6 7 8
摘要:https://leetcode.com/problems/next-greater-element-ii/description/ 阅读全文
posted @ 2018-05-04 14:29 JTechRoad 阅读(132) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/next-greater-element-i/description/ 阅读全文
posted @ 2018-05-04 14:16 JTechRoad 阅读(120) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/shortest-completing-word/description/ 阅读全文
posted @ 2018-05-04 08:25 JTechRoad 阅读(130) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/01-matrix/description/ Use BFS to search. First I tried to BFS every 0, the problem is each 1 may need to be visited for 阅读全文
posted @ 2018-05-04 00:02 JTechRoad 阅读(148) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/find-eventual-safe-states/description/ 阅读全文
posted @ 2018-05-03 14:22 JTechRoad 阅读(151) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/maximum-width-of-binary-tree/description/ 阅读全文
posted @ 2018-05-03 13:55 JTechRoad 阅读(135) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/top-k-frequent-words/description/ 阅读全文
posted @ 2018-05-03 13:17 JTechRoad 阅读(156) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/expressive-words/description/ 阅读全文
posted @ 2018-05-03 13:01 JTechRoad 阅读(284) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/valid-parenthesis-string/description/ 这个题的难点在增加了*,*可能是(也可能是)。是(的前提是:右边有多余的)。是)的前提是:左边有多余的(。所以他们的位置信息是重要的。 Valid Parenthe 阅读全文
posted @ 2018-05-03 08:30 JTechRoad 阅读(129) 评论(0) 推荐(0)
摘要:Brute force (time out) Preprocess S: 阅读全文
posted @ 2018-05-02 23:44 JTechRoad 阅读(131) 评论(0) 推荐(0)
摘要:DP 阅读全文
posted @ 2018-05-02 12:41 JTechRoad 阅读(164) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/edit-distance/description/ DP 递归 (bad performance, should change cache key to index [i,j] in the two words) 阅读全文
posted @ 2018-05-02 07:23 JTechRoad 阅读(93) 评论(0) 推荐(0)
摘要:class Solution { public: double largestSumOfAverages(vector& A, int K) { int n = A.size(); // dp[k][i]: largestSumOfAverages of [0,i] with up to k partitions // d... 阅读全文
posted @ 2018-05-02 02:47 JTechRoad 阅读(255) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/cheapest-flights-within-k-stops/description/ DFS (slow) BFS (seems not able to use BFS as below, we may have to record e 阅读全文
posted @ 2018-05-01 23:33 JTechRoad 阅读(429) 评论(0) 推荐(0)
摘要:https://leetcode.com/problems/largest-number-at-least-twice-of-others/description/ 阅读全文
posted @ 2018-05-01 12:42 JTechRoad 阅读(123) 评论(0) 推荐(0)
摘要:When to use binary search: * 我们知道解空间在一个区间 [i,j] * valid解是解空间的一个点(也可以看作是只有一个点的range)或者一个range的起始点或者结束点 * range之外的点都不是valid解 想法一般都两种: * 直接找到解 (比如classic 阅读全文
posted @ 2018-05-01 08:32 JTechRoad 阅读(216) 评论(0) 推荐(0)
摘要:class Solution { public: // O(n) // The idea is to maintain a window for all chars seen so far. // For [1,0,2,3,4], i = 0, we know the window should at least end on pos[i=0]=1. // For... 阅读全文
posted @ 2018-04-30 15:20 JTechRoad 阅读(139) 评论(0) 推荐(0)
摘要:https://www.programcreek.com/2013/08/leetcode-problem-classification/ https://medium.com/algorithms-and-leetcode https://medium.com/@sourabreddy 阅读全文
posted @ 2018-04-30 15:18 JTechRoad 阅读(102) 评论(0) 推荐(0)

上一页 1 ··· 4 5 6 7 8