摘要: Because of lots dups in dict, better to use hash set to filter it out. 阅读全文
posted @ 2017-08-30 15:43 keepshuatishuati 阅读(108) 评论(0) 推荐(0) 编辑
摘要: class Solution { public boolean increasingTriplet(int[] nums) { if (nums.length < 3) { return false; } int small = Integer.MAX_VALUE; int middle = Inte... 阅读全文
posted @ 2017-08-30 14:44 keepshuatishuati 阅读(69) 评论(0) 推荐(0) 编辑
摘要: It's like the packing problem. Brute force: 阅读全文
posted @ 2017-08-30 14:28 keepshuatishuati 阅读(83) 评论(0) 推荐(0) 编辑
摘要: We can avoid more duplicate work by check [0, haystack - needle + 1] length. Need to revisit KMP 阅读全文
posted @ 2017-08-30 14:14 keepshuatishuati 阅读(74) 评论(0) 推荐(0) 编辑
摘要: Follow up questions, what if dup allows: 1. Map<Value, Queue<Indexes>> if it looks like a queue first in first out. 2. Map<Value, Map<Index, Indexes>> 阅读全文
posted @ 2017-08-30 13:55 keepshuatishuati 阅读(77) 评论(0) 推荐(0) 编辑
摘要: class Solution { public int longestConsecutive(int[] nums) { if (nums.length set = new HashSet(); for (int num : nums) { set.add(num); } i... 阅读全文
posted @ 2017-08-30 13:23 keepshuatishuati 阅读(90) 评论(0) 推荐(0) 编辑