Skip to content

Commit c6544b2

Browse files
refactor 706
1 parent 570a498 commit c6544b2

File tree

1 file changed

+29
-0
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+29
-0
lines changed

src/main/java/com/fishercoder/solutions/_706.java

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package com.fishercoder.solutions;
22

3+
import java.util.Arrays;
4+
35
public class _706 {
46
public static class Solution1 {
57
/**
@@ -163,4 +165,31 @@ public void remove(int key) {
163165
}
164166
}
165167
}
168+
169+
public static class Solution3 {
170+
/**
171+
* My completely original, but hacky and cheaty solution to take full advantage of the problem constraints.
172+
*/
173+
public static class MyHashMap {
174+
175+
int[] map;
176+
177+
public MyHashMap() {
178+
map = new int[1000001];
179+
Arrays.fill(map, -1);
180+
}
181+
182+
public void put(int key, int value) {
183+
map[key] = value;
184+
}
185+
186+
public int get(int key) {
187+
return map[key];
188+
}
189+
190+
public void remove(int key) {
191+
map[key] = -1;
192+
}
193+
}
194+
}
166195
}

0 commit comments

Comments
 (0)