map | set | T.C O(nlog(n)) | clean code
IntuitionApproachComplexity
Time complexity:
change() T.C. = O(n*log(n))
find() T.C. = O(1)
Space complexity:
O(2n)Code
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
change() T.C. = O(n*log(n))
find() T.C. = O(1)

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(2n)
# Code
```cpp []
class NumberContainers {
public:

unordered_map<int,set<int>>m1;
unordered_map<int,int>m2;

    NumberContainers() {
        
    }
    
    void change(int i, int n) {
        if(m2.find(i)!=m2.end()){
            int num = m2[i];
            m1[num].erase(i);
            if(m1[num].size()==0){
                m1.erase(num);
            }
        }
        m1[n].insert(i);
        m2[i] = n;
    }
    
    int find(int n) {
        if(m1.find(n)!=m1.end()) return *m1[n].begin();
        return -1;
    }
};

/**
 * Your NumberContainers object will be instantiated and called as such:
 * NumberContainers* obj = new NumberContainers();
 * obj->change(index,number);
 * int param_2 = obj->find(number);
 */
```
['Hash Table', 'Ordered Set', 'C++']