Skip to content

Commit 8d019b6

Browse files
edit 219
1 parent 3154532 commit 8d019b6

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ Your ideas/fixes/algorithms are more than welcome!
356356
|223|[Rectangle Area](https://leetcode.com/problems/rectangle-area/)|[Solution](../master/src/main/java/com/fishercoder/solutions/RectangleArea.java)| O(1)|O(1) | Easy|
357357
|222|[Count Complete Tree Nodes](https://leetcode.com/problems/count-complete-tree-nodes/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_222.java)| O(?)|O(h) | Medium| Recursion
358358
|220|[Contains Duplicate III](https://leetcode.com/problems/contains-duplicate-iii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/ContainsDuplicateIII.java)| O(nlogn)|O(n) | Medium| TreeSet
359-
|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/ContainsDuplicateII.java)| O(n)|O(n) | Easy| HashMap
359+
|219|[Contains Duplicate II](https://leetcode.com/problems/contains-duplicate-ii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_219.java)| O(n)|O(n) | Easy| HashMap
360360
|218|[The Skyline Problem](https://leetcode.com/problems/the-skyline-problem/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_218.java)| O(n)|O(n) | Hard| TreeMap, Design
361361
|217|[Contains Duplicate](https://leetcode.com/problems/contains-duplicate/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_217.java)| O(n)|O(n) | Easy| HashSet
362362
|216|[Combination Sum III](https://leetcode.com/problems/combination-sum-iii/)|[Solution](../master/src/main/java/com/fishercoder/solutions/_216.java)| O(k * C(n, k))|O(k) | Medium| Backtracking

src/main/java/com/fishercoder/solutions/ContainsDuplicateII.java renamed to src/main/java/com/fishercoder/solutions/_219.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
/**219. Contains Duplicate II
77
*
88
Given an array of integers and an integer k, find out whether there are two distinct indices i and j in the array such that nums[i] = nums[j] and the difference between i and j is at most k.*/
9-
public class ContainsDuplicateII {
9+
public class _219 {
10+
1011
//pretty straightforward, use a hashmap, key is the number itself, value is the last index that this value appeared in the array
1112
//we can keep updating the value as we move forward, since if the current index minus the last index cannot be smaller than k, then
1213
//the later indices won't even do either. So, we only need to keep one index in the value of the HashMap. Cheers!

0 commit comments

Comments
 (0)