摘要: 参考: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 public class Codec 2 { 3 // Encodes a tree to a single string. 4 public string serialize(TreeNode root) 5 { 6 if (root == null) 7 ... 阅读全文
posted @ 2019-03-06 13:35 Sempron2800+ 阅读(330) 评论(0) 推荐(0) 编辑
摘要: 1 public class Solution 2 { 3 public double FindMedianSortedArrays(int[] nums1, int[] nums2) 4 { 5 var nums = nums1.Concat(nums2).OrderBy(x => x).ToArray(); 6 ... 阅读全文
posted @ 2019-03-06 09:28 Sempron2800+ 阅读(332) 评论(0) 推荐(0) 编辑
摘要: 投机取巧的办法,时间复杂度还可以,空间占用比较多。 阅读全文
posted @ 2019-03-06 09:13 Sempron2800+ 阅读(201) 评论(0) 推荐(0) 编辑
摘要: 这是《趣学算法》一书中4-4节提供的代码,在leetcode上运行,速度比较慢,392ms(5.16%),12.9mb(5.22%)。 补充一个python的实现: 240ms,16.4mb 下面提供leetcode中一个12ms,8.5mb的解决方案: 将第二种写法,转化为python语法: 20 阅读全文
posted @ 2019-03-06 08:50 Sempron2800+ 阅读(251) 评论(0) 推荐(0) 编辑