C++ | One Map Solution
Declare map of int int\n\nvoid change() - map[index] = number // this will store the number at given index\n\nvoid find() - As the second parameter of map is th
Declare map of int int\n\n**void change()** - map[index] = number *// this will store the number at given index*\n\n**void find()** - As the second parameter of map is the number we are looking for, run a for loop and check if the number is present or not else return -1.\nAs the map is sorted w.r.t index, it will return the smallest index for that number :)\n\neg -\nmap[1]= 20\nmap[2]= 10\nmap[4]= 10\nmap[7]= 10\n\nfor find(10) - it will return the smallest index it encounterd i.e. **2**\n\n**C++ Approch :**\n```\nclass NumberContainers {\npublic:\n    map<int,int> mp;\n    void change(int index, int number) {\n        mp[index] = number;\n    }\n    int find(int number) {\n        for(auto it:mp) if(it.second==number) return it.first;\n        return -1;\n    }\n};\n```\n\nUpvote if it helped you ; )
['C++']