C++ | map and set
Code:\ncpp\nclass NumberContainers {\npublic:\n    map<int, int> keyToVal;\n    map<int, set<int>> index;\n    NumberContainers() {}\n    \n    void change(int 
**Code:**\n```cpp\nclass NumberContainers {\npublic:\n    map<int, int> keyToVal;\n    map<int, set<int>> index;\n    NumberContainers() {}\n    \n    void change(int indx, int number) {\n        if(keyToVal.find(indx) != keyToVal.end())\n        {\n            int oldVal = keyToVal[indx];\n            index[oldVal].erase(indx);\n        }\n        keyToVal[indx] = number;\n        index[number].insert(indx);\n    }\n    \n    int find(int number) {\n        if(index[number].size() == 0) return -1;\n        return *(index[number].begin());\n    }\n};\n```
[]