@@ -0,0 +1,2872 @@
+package org.pilgrim.leetcode.y2021;%0A%0Aimport java.util.Iterator;%0Aimport java.util.LinkedList;%0A%0Aclass DesignHashMap %7B%0A      int key;%0A      int val;%0A%7D%0A%0Aclass MyHashMap %7B%0A    %0A    LinkedList%3CDesignHashMap%3E%5B%5D arr = new LinkedList%5B1000%5D;%0A%0A    /** Initialize your data structure here. */%0A    public MyHashMap() %7B%0A        %0A    %7D%0A    %0A    /** value will always be non-negative. */%0A    public void put(int key, int value) %7B%0A        int size = arr.length;%0A        int index = key %25 size;%0A        %0A        LinkedList%3CDesignHashMap%3E map = arr%5Bindex%5D;%0A        if(map == null)%7B%0A            map = new LinkedList%3CDesignHashMap%3E();%0A            arr%5Bindex%5D = map;%0A        %7D%0A        %0A        DesignHashMap found = null;%0A        int i = -1;%0A        Iterator%3CDesignHashMap%3E iterator = map.iterator();%0A        while (iterator.hasNext()) %7B%0A            DesignHashMap kv = iterator.next();%0A            i++;%0A            if(kv.key == key)%7B%0A                found = kv;%0A                break;%0A            %7D%0A        %7D%0A        %0A        if(found != null)%7B%0A            found.val = value;%0A        %7D%0A        else%7B%0A            DesignHashMap kv = new DesignHashMap();%0A            kv.key = key;%0A            kv.val = value;%0A            map.add(kv);%0A        %7D%0A    %7D%0A    %0A    /** Returns the value to which the specified key is mapped, or -1 if this map contains no mapping for the key */%0A    public int get(int key) %7B%0A        int size = arr.length;%0A        int index = key %25 size;%0A        %0A        LinkedList%3CDesignHashMap%3E map = arr%5Bindex%5D;%0A        if(map == null)%7B%0A            return -1;%0A        %7D%0A        %0A        DesignHashMap found = null;%0A        Iterator%3CDesignHashMap%3E iterator = map.iterator();%0A        while (iterator.hasNext()) %7B%0A            DesignHashMap kv = iterator.next();%0A            if(kv.key == key)%7B%0A                found = kv;%0A                break;%0A            %7D%0A        %7D%0A        %0A        if(found != null)%7B%0A            return found.val;%0A        %7D%0A        else%7B%0A            return -1;%0A        %7D%0A    %7D%0A    %0A    /** Removes the mapping of the specified value key if this map contains a mapping for the key */%0A    public void remove(int key) %7B%0A        int size = arr.length;%0A        int index = key %25 size;%0A        %0A        LinkedList%3CDesignHashMap%3E map = arr%5Bindex%5D;%0A        if(map == null)%7B%0A            return;%0A        %7D%0A        %0A        DesignHashMap found = null;%0A        Iterator%3CDesignHashMap%3E iterator = map.iterator();%0A        while (iterator.hasNext()) %7B%0A            DesignHashMap kv = iterator.next();%0A            if(kv.key == key)%7B%0A                iterator.remove();%0A                break;%0A            %7D%0A        %7D%0A        %0A        if(map.isEmpty())%7B%0A            arr%5Bindex%5D = null;%0A        %7D%0A    %7D%0A%7D%0A%0A/**%0A * Your MyHashMap object will be instantiated and called as such:%0A * MyHashMap obj = new MyHashMap();%0A * obj.put(key,value);%0A * int param_2 = obj.get(key);%0A * obj.remove(key);%0A */

add Design HashMap