forked from fishercoder1534/Leetcode
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path_705.java
36 lines (30 loc) · 848 Bytes
/
_705.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package com.fishercoder.solutions;
import java.util.HashMap;
import java.util.Map;
public class _705 {
public static class Solution1 {
class MyHashSet {
Map<Integer, Integer> map;
/**
* Initialize your data structure here.
*/
public MyHashSet() {
map = new HashMap<>();
}
public void add(int key) {
map.put(key, 0);
}
public void remove(int key) {
if (map.containsKey(key)) {
map.remove(key);
}
}
/**
* Returns true if this set contains the specified element
*/
public boolean contains(int key) {
return map.containsKey(key);
}
}
}
}