g0701_0800.s0705_design_hashset.MyHashSet Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of leetcode-in-java Show documentation
Show all versions of leetcode-in-java Show documentation
Java-based LeetCode algorithm problem solutions, regularly updated
package g0701_0800.s0705_design_hashset;
// #Easy #Array #Hash_Table #Design #Linked_List #Hash_Function
public class MyHashSet {
private final boolean[] arr;
public MyHashSet() {
arr = new boolean[1000001];
}
public void add(int key) {
arr[key] = true;
}
public void remove(int key) {
arr[key] = false;
}
public boolean contains(int key) {
return arr[key];
}
}