[C++] | Map & Map with Set
Approach\nI maintain 2 maps one is for index to number mapping. And other is for number to index storing. \nWe have to output the smallest index and set can han
**Approach**\nI maintain `2` maps one is for `index` to `number` mapping. And other is for `number` to `index` storing. \nWe have to output the `smallest index` and `set` can handle this thing easily.\n\n**Time:** `change: O(log N), find: O(log N), N = Number of elements present in the bucket`\n**Space:** `O(M), M = Number of elements inserted with change function`\n\n```\nclass NumberContainers {\nprivate:\n    unordered_map<int, set<int>> maps;\n    unordered_map<int, int> index_to_num;\npublic:\n    NumberContainers() {\n        \n    }\n    \n    void change(int index, int number) {\n        if (index_to_num.count(index)) {\n            maps[index_to_num[index]].erase(index);\n            index_to_num[index] = number;\n            maps[number].insert(index);\n        } else {\n            index_to_num[index] = number;\n            maps[number].insert(index);\n        }\n    }\n    \n    int find(int number) {\n        if (maps[number].size()) {\n            return *maps[number].begin();\n        } else {\n            return -1;\n        }\n    }\n};\n```
['C', 'Ordered Set']