Set
class MyHashSet {
private Integer[] values = new Integer[1000000];
public void add(int key) {
values[hash(key)] = key;
}
public void remove(int key) {
values[hash(key)] = null;
}
/** Returns true if this set did not already contain the specified element */
public boolean contains(int key) {
return values[hash(key)] != null;
}
public int hash(int value) {
return values.length % value;
}
}Advanced hashing and re-sizing hash set.
Linked List to handle equals values but the same positions
Last updated