Map and set | Aasan hai | C++
\nclass NumberContainers {\npublic:\n    \n    // key: number | value: indices in the set -> used for finding indices associated with the number\n    unordered_
```\nclass NumberContainers {\npublic:\n    \n    // key: number | value: indices in the set -> used for finding indices associated with the number\n    unordered_map<int, set<int>> m;\n    \n    // key: index | value: number -> used for searching the index with number\n    unordered_map<int, int> s;\n    \n    NumberContainers() {}\n    \n    void change(int index, int number) {\n        // if that index was earlier present then clear that index from old number and delete from s map.\n        if(s.find(index) != s.end()){\n            m[s[index]].erase(m[s[index]].find(index));\n            if(m[s[index]].size() == 0)m.erase(s[index]); // if set is empty then delete the key from map.\n        }\n        \n        m[number].insert(index);\n        s[index]=number;\n    }\n    \n    int find(int number) {\n        //if number found as key then return first element.\n        if(m.find(number) != m.end()){\n            return *m[number].begin();\n        }\n        else return -1;\n    }\n};\n\n/**\n * Your NumberContainers object will be instantiated and called as such:\n * NumberContainers* obj = new NumberContainers();\n * obj->change(index,number);\n * int param_2 = obj->find(number);\n */\n```
['Ordered Set']