HASHING | JAVA | TREE SET
I Used 2 map to solve this Problems\nfirst one (map) which is of type Int, set , which stores all the number with the index in which the number is present\nSeco
I Used 2 map to solve this Problems\nfirst one (map) which is of type Int, set , which stores all the number with the index in which the number is present\nSecond one , will store the index and , number corresponding to that index\n\nchange  function :-\nsimply push the index number in first map, \nand change the value at index in second map\n\nfind function :-\niterate through the tree set corresponding to that number,\nand the return the first index in which that no is present , \n\nif no number satisfy the condition simply return -1;\n\nHappy Coding :)\n***Upvote the post , if you learn something from it***\n```\nclass NumberContainers {\n    \n    Map<Integer,TreeSet<Integer>> map;\n    Map<Integer,Integer> m;\n    public NumberContainers() {\n        map=new HashMap<>();\n        m=new HashMap<>();\n        \n    }\n    public void change(int index, int number) {\n        m.put(index,number);\n        if(!map.containsKey(number)) map.put(number,new TreeSet<>());\n        map.get(number).add(index);\n    }\n    \n    public int find(int number) {\n        if(!map.containsKey(number)) return -1;\n        for(Integer a:map.get(number)){\n            if(m.get(a)==number) return a;\n        }\n        return -1;\n    }\n}\n```
['Tree', 'Ordered Set', 'Java']