上一页 1 ··· 66 67 68 69 70 71 72 73 74 ··· 114 下一页
摘要: 第一次遍历:用一个map记录所有出现过的值,这里忽略掉所有非正数(小于等于0的)。 第二次遍历:从1开始,判断是否在map中,如果在map中继续判断下一个数字,一直到第一个不在字典中的值,则为所求。 17-25行是想写个do while,但是感觉怪怪的。 复杂的算法虽好但是想多了容易掉头发,有时性能 阅读全文
posted @ 2019-03-07 20:08 Sempron2800+ 阅读(155) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/longest-valid-parentheses/discuss/14126/My-O(n)-solution-using-a-stack 补充一个python的实现: 阅读全文
posted @ 2019-03-07 12:00 Sempron2800+ 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/burst-balloons/discuss/76228/Share-some-analysis-and-explanations 补充一个python的实现: 阅读全文
posted @ 2019-03-07 11:55 Sempron2800+ 阅读(148) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/regular-expression-matching/discuss/5651/Easy-DP-Java-Solution-with-detailed-Explanation 补充一个python的实现: 本题与剑指Offer 19 阅读全文
posted @ 2019-03-07 11:51 Sempron2800+ 阅读(237) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/maximal-rectangle/discuss/29055/My-java-solution-based-on-Maximum-Rectangle-in-Histogram-with-explanation 补充一个python的 阅读全文
posted @ 2019-03-07 11:48 Sempron2800+ 阅读(179) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/binary-tree-maximum-path-sum/discuss/39775/Accepted-short-solution-in-Java 阅读全文
posted @ 2019-03-07 11:12 Sempron2800+ 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/remove-invalid-parentheses/discuss/75027/Easy-Short-Concise-and-Fast-Java-DFS-3-ms-solution 阅读全文
posted @ 2019-03-07 11:01 Sempron2800+ 阅读(171) 评论(0) 推荐(0) 编辑
摘要: 参考:https://www.geeksforgeeks.org/largest-rectangle-under-histogram/ 补充一个python的实现: 采用了一个小技巧,在heights最后补一个0,则21行到27行的代码就可以省略了。 阅读全文
posted @ 2019-03-06 22:31 Sempron2800+ 阅读(309) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution: 2 def minWindow(self, s: str, t: str) -> str: 3 n = len(s) 4 if n==0: 5 return "" 6 if len(t)==0: 7 return s 8 #i... 阅读全文
posted @ 2019-03-06 21:45 Sempron2800+ 阅读(227) 评论(0) 推荐(0) 编辑
摘要: 1 public class LRUCache 2 { 3 int Capacity = 0; 4 int Curlen = 0; 5 long sernumbers; 6 long SerNumbers 7 { 8 get 9 { 10 if (sernumbers <= long.MaxValu 阅读全文
posted @ 2019-03-06 19:26 Sempron2800+ 阅读(174) 评论(0) 推荐(0) 编辑
上一页 1 ··· 66 67 68 69 70 71 72 73 74 ··· 114 下一页