Skip to content

Commit 620a107

Browse files
Merge pull request codemistic#460 from Aman5989/patch-12
create design-hashset.java
2 parents 6ee6099 + ca7bcea commit 620a107

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Hashtable/design-hashset.java

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
int size = (int)Math.pow(10, 6)+1;
2+
boolean[] flag;
3+
public MyHashSet() {
4+
flag = new boolean[size];
5+
}
6+
7+
public void add(int key) {
8+
flag[key]=true;
9+
}
10+
11+
public void remove(int key) {
12+
flag[key]=false;
13+
}
14+
15+
public boolean contains(int key) {
16+
return flag[key];
17+
}

0 commit comments

Comments
 (0)