摘要:
暴力枚举会LTE,解题思路是用sortedSet来解决,sortedSet可以返回一个在某个范围的subSet,同时判断这个subSet是否为空即可解决,主要,本题需要使用long类型! 时间 O(NlogK) 空间 O(K) 思路 要求判断之前是否存在差值小于t的数字,我们需要知道在当前数字x两边 阅读全文
posted @ 2015-12-18 23:31
neverlandly
阅读(269)
评论(0)
推荐(0)
摘要:
nvert a binary tree. 4 / \ 2 7 / \ / \1 3 6 9to 4 / \ 7 2 / \ / \9 6 3 1Trivia:This problem was inspired by this... 阅读全文
posted @ 2015-12-18 13:14
neverlandly
阅读(287)
评论(0)
推荐(0)
摘要:
参考了http://www.cnblogs.com/tonyluis/p/4564617.html 复杂度 Time Complexity is O(n^2) because removal in a PQ is O(n), 空间 O(N) I think if replace PQ with Tr 阅读全文
posted @ 2015-12-18 12:27
neverlandly
阅读(268)
评论(0)
推荐(0)
摘要:
如果跟Word Search做法一样,还按照DFS回溯的方法,逐个检查每个word是否在board里,显然效率是比较低的。我们可以利用Trie数据结构,也就是前缀树。然后dfs时,如果当前形成的单词不在Trie里,就没必要继续dfs下去了。如果当前字符串在trie里,就说明board可以形成这个wo 阅读全文
posted @ 2015-12-18 03:22
neverlandly
阅读(533)
评论(0)
推荐(0)
摘要:
Find the total area covered by two rectilinear rectangles in a 2D plane.Each rectangle is defined by its bottom left corner and top right corner as sh... 阅读全文
posted @ 2015-12-18 00:48
neverlandly
阅读(324)
评论(0)
推荐(0)
浙公网安备 33010602011771号