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) 编辑