Two Maps
We map an index to a number, and a number to all its indexes (we use a set so indexes are sorted).\n\nFor change, we use the first map to get the previous numbe
We map an index to a number, and a number to all its indexes (we use a set so indexes are sorted).\n\nFor `change`, we use the first map to get the previous number for the index.\n    \nThen, we remove that index from the second map for the previous number. \n\n**C++**\n```cpp\nclass NumberContainers {\npublic:\n    unordered_map<int, int> ind_num;\n    unordered_map<int, set<int>> num_inds;\n    void change(int index, int number) {\n        auto it = ind_num.find(index);\n        if (it != end(ind_num))\n            num_inds[it->second].erase(index);\n        ind_num[index] = number;\n        num_inds[number].insert(index);\n    }\n    int find(int number) {\n        auto it = num_inds.find(number);\n        return it == end(num_inds) || it->second.empty() ? -1 : *begin(it->second);\n    }\n};
[]