2019年4月7日
摘要: Compared with contains duplicate II, we should record a sorted set within the length k window. So when we visit a new value, we can get the floor and 阅读全文
posted @ 2019-04-07 23:10 王 帅 阅读(95) 评论(0) 推荐(0) 编辑
摘要: Keep a window of width k, before visit new element, remove nums[i k 1]. Other details are much the same as Contains Duplicate. 阅读全文
posted @ 2019-04-07 22:55 王 帅 阅读(86) 评论(0) 推荐(0) 编辑
摘要: ```java class Solution { public boolean containsDuplicate(int[] nums) { Set s = new HashSet(); for (int val: nums) { if (!s.add(val)) return true; } ret... 阅读全文
posted @ 2019-04-07 22:51 王 帅 阅读(77) 评论(0) 推荐(0) 编辑
摘要: ```java class Solution { public int findDuplicate(int[] nums) { int N = nums.length; int l = 1, r = N - 1; while (l mid) { r = mid; } ... 阅读全文
posted @ 2019-04-07 22:48 王 帅 阅读(102) 评论(0) 推荐(0) 编辑
  2019年4月4日
摘要: one pass method with wile java class Solution { public int[] sortArrayByParityII(int[] A) { int i = 1, j = 0; int N = A.length; while (i = N) return A 阅读全文
posted @ 2019-04-04 23:03 王 帅 阅读(105) 评论(0) 推荐(0) 编辑
摘要: When dealing with combination number problems, I think easy to write code is better than fast code..... java class Solution { public int threeSumMulti 阅读全文
posted @ 2019-04-04 22:38 王 帅 阅读(118) 评论(0) 推荐(0) 编辑
  2019年4月3日
摘要: This problem has very detailed solution. So just check out the solution page. Method 1: Use monotone stack to record the leftmost and rightmost index. 阅读全文
posted @ 2019-04-03 23:10 王 帅 阅读(72) 评论(0) 推荐(0) 编辑
  2019年3月31日
摘要: ```java class Solution { public boolean isLongPressedName(String name, String typed) { int i = 0, j = 0; while (i 阅读全文
posted @ 2019-03-31 18:35 王 帅 阅读(99) 评论(0) 推荐(0) 编辑
摘要: ```java class Solution { public int numUniqueEmails(String[] emails) { Set s = new HashSet(); for (String e: emails) { int idx = e.indexOf("@"); String host... 阅读全文
posted @ 2019-03-31 09:39 王 帅 阅读(65) 评论(0) 推荐(0) 编辑
  2019年3月29日
摘要: This problem has very detailed solution. So just check out the solution page. Method 1: Use monotone stack to record the leftmost and rightmost index. 阅读全文
posted @ 2019-03-29 21:26 王 帅 阅读(83) 评论(0) 推荐(0) 编辑