上一页 1 ··· 65 66 67 68 69 70 71 72 73 ··· 114 下一页
摘要: 这道题的思路就是把运算映射到数组的index上,形成一种规律的运算方式,在循环中进行处理。 阅读全文
posted @ 2019-03-10 20:38 Sempron2800+ 阅读(99) 评论(0) 推荐(0) 编辑
摘要: 上面这个一定觉得很啰嗦,那就来个简单的: 思想是一样的,但是简洁了很多。而且由于没有使用新数组保存正和负数,所以空间占用更小。 第一部分代码是思维的过程,第二部分代码是提炼之后的。leetcode上面的题目,大部分都可以用20,30行就搞定。如果代码特别长,那应该是没有抓住问题的本质,这样的代码思维 阅读全文
posted @ 2019-03-10 19:03 Sempron2800+ 阅读(129) 评论(0) 推荐(0) 编辑
摘要: 神题神解, 参考1:https://leetcode.com/problems/the-skyline-problem/discuss/61194/108-ms-17-lines-body-explained 参考2:https://briangordon.github.io/2014/08/the 阅读全文
posted @ 2019-03-08 16:15 Sempron2800+ 阅读(149) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/word-search-ii/discuss/59780/Java-15ms-Easiest-Solution-(100.00) 阅读全文
posted @ 2019-03-08 16:07 Sempron2800+ 阅读(200) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/max-points-on-a-line/discuss/47113/A-java-solution-with-notes 阅读全文
posted @ 2019-03-08 16:02 Sempron2800+ 阅读(233) 评论(0) 推荐(0) 编辑
摘要: 1 class Solution(object): 2 def wordBreak(self, s, wordDict): 3 """ 4 :type s: str 5 :type wordDict: Set[str] 6 :rtype: List[str] 7 """ 8 r... 阅读全文
posted @ 2019-03-08 16:00 Sempron2800+ 阅读(143) 评论(0) 推荐(0) 编辑
摘要: 参考:https://leetcode.com/problems/wildcard-matching/discuss/429337/Java%3A-Wild-card! 补充一个python的实现: 思路:动态规划。 举例分析:s='acdcb' p='a*c?b' 。s长度为m,p长度为n。 初始 阅读全文
posted @ 2019-03-08 15:51 Sempron2800+ 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 从后向前进行判断,线性的搜索时间复杂度比较高,因此建立一个二叉搜索树,每次插入节点的时候,更新父节点的“右侧小”的数字的数量。 参考:https://leetcode.com/problems/count-of-smaller-numbers-after-self/discuss/76587/Eas 阅读全文
posted @ 2019-03-08 11:40 Sempron2800+ 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 1 public class Solution 2 { 3 bool[,] tags;//用于标记是否已经访问过,false未访问,true已访问 4 int[,] records;//用于标记以当前为起点的最长升序列长度(上下左右四向最长的) 5 6 private int MaxOfFour(int a, in... 阅读全文
posted @ 2019-03-08 10:25 Sempron2800+ 阅读(255) 评论(0) 推荐(0) 编辑
摘要: 1 public class MedianFinder 2 { 3 List list = null; 4 int count = 0; 5 /** initialize your data structure here. */ 6 public MedianFinder() 7 { 8 ... 阅读全文
posted @ 2019-03-07 23:05 Sempron2800+ 阅读(193) 评论(0) 推荐(0) 编辑
上一页 1 ··· 65 66 67 68 69 70 71 72 73 ··· 114 下一页