Design a HashMap without using any built-in hash table libraries.

PHOTO EMBED

Fri Apr 22 2022 14:27:23 GMT+0000 (Coordinated Universal Time)

Saved by @selvendhiran11 #java

class MyHashMap {
    int[] arr;

    public MyHashMap() {
        arr = new int[(int) Math.pow(10,6)+1];
        Arrays.fill(arr,-1);
        
    }
    
    public void put(int key, int value) {
        arr[key] = value;
    }
    
    public int get(int key) {
        return arr[key];
    }
    
    public void remove(int key) {
        arr[key] = -1;
    }
}

/**
 * Your MyHashMap object will be instantiated and called as such:
 * MyHashMap obj = new MyHashMap();
 * obj.put(key,value);
 * int param_2 = obj.get(key);
 * obj.remove(key);
 */
content_copyCOPY

https://leetcode.com/problems/design-hashmap/