705. 设计哈希集合
代码:
class MyHashSet {
/** Initialize your data structure here. */
Set<Integer> set ;
public MyHashSet() {
set = new HashSet<>();
}
public void add(int key) {
set.add(key);
}
public void remove(int key) {
if (set.contains(key)) set.remove(key);
}
/** Returns true if this set contains the specified element */
public boolean contains(int key) {
return set.contains(key);
}
}