摘要:
Solution: Use HashTable, Time: O(N^2), Space: O(N) 我的:注意14行是有value个重复distance,表示有value个点,他们跟指定点距离都是distance,需要选取2个做permutation, 所以是value * (value-1) 别 阅读全文
posted @ 2016-12-07 13:51
neverlandly
阅读(496)
评论(0)
推荐(0)
摘要:
count is the # of level, sum is the accumulated coins Better Solution: Binary Search, 因为怕溢出,所以(1+m)m/2表示成了line6那种样子. 用m去估计最后返回的row 阅读全文
posted @ 2016-12-07 13:44
neverlandly
阅读(291)
评论(0)
推荐(0)
摘要:
Add the prefix sum to the hashMap, and check along path if hashMap.contains(pathSum+cur.val-target); My Solution 一个更简洁的solution: using HashMap to stor 阅读全文
posted @ 2016-12-07 12:17
neverlandly
阅读(612)
评论(0)
推荐(0)
摘要:
Solution: O(1) time complexity 解题思路主要参考了网友ivancjw的帖子,数据结构参考了https://discuss.leetcode.com/topic/65634/java-ac-all-strict-o-1-not-average-o-1-easy-to-re 阅读全文
posted @ 2016-12-07 09:09
neverlandly
阅读(1428)
评论(0)
推荐(0)
摘要:
Solution 1: TreeMap, Time complexity: O(NlogN) 像这种在一个集合里面寻找有没有比某个数小的数,一般要么treeMap要么treeSet。Interval的题经常需要用treeMap, Data Stream as Disjoint Intervals 就 阅读全文
posted @ 2016-12-07 04:53
neverlandly
阅读(449)
评论(0)
推荐(0)
摘要:
Actually, the problem is the same as "Given a collection of intervals, find the maximum number of intervals that are non-overlapping." (the classic Gr 阅读全文
posted @ 2016-12-07 01:28
neverlandly
阅读(765)
评论(0)
推荐(0)
摘要:
用split() 不用API, better solution, O(N) time O(1) space 阅读全文
posted @ 2016-12-07 00:36
neverlandly
阅读(417)
评论(0)
推荐(0)
浙公网安备 33010602011771号