摘要:
我的binary Search 解法:无需变成long 别人三种方法总结: 阅读全文
摘要:
用HashMap Follow Up 1: 用two pointer解,可以省存成HashMap Follow Up 2: 用在长的数组里面binary Search可解 Follow Up 3: What if elements of nums2 are stored on disk, and t 阅读全文
摘要:
Use two hash sets Time complexity: O(n) 注意Set<Integer> set = new HashSet<>(); 第二个泛型可以不写出 Iterator iter = set2.iterator(); for (int i=0; i<res.length; 阅读全文
摘要:
很像majority element III, 但是那道题有O(k) extra space的限制,这里没有。有任意extra space, 同时知道elem range情况下,bucket sort最节省时间 语法上注意第5行,建立一个ArrayList的array,后面没有泛型generic L 阅读全文
摘要:
Two Pointers 解法, 注意大小写 阅读全文
摘要:
O(N^2)解法: DP dp[i] represent the maximum product of breaking up integer i O(N)解法: the best factor is 3. we keep breaking n into 3's until n gets small 阅读全文
摘要:
非常精巧地使用stack。push all the nestedList into the stack from back to front,so when we pop the stack, it returns the very first element 执行hasNext()的时候,如果pe 阅读全文