C++ O(log n) solution 
IntuitionWe can use :
Hash map --> to store the number assigned to each index
Set --> to store indices for each number
ApproachComplexity
Time complexity:
Chang
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->
We can use : 
- **Hash map** --> to store the number assigned to each index
- **Set** --> to store indices for each number

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

# Complexity
- Time complexity:
<!-- Add your time complexity here, e.g. $$O(n)$$ -->
```Change ``` : O(logn) (due to set insert/erase).
```find```: O(1) (returning the smallest element from a set).

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->
O(n) (for storing indices in mp1 and mp2)

# Code
```cpp []
class NumberContainers {
    unordered_map<int, int> mp1;
    unordered_map<int, set<int>> mp2;

public:
    NumberContainers() {}

    void change(int index, int number) {
        if (mp1.find(index) == mp1.end())
            mp1[index] = number;
        else {
            int num = mp1[index];
            mp2[num].erase(index);
            if (mp2[num].empty()) {
                mp2.erase(num);
            }
        }
        mp2[number].insert(index);
        mp1[index] = number;
    }

    int find(int number) {
        if (mp2.find(number) != mp2.end() && !mp2[number].empty())
            return *mp2[number].begin();
        else
            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);
 */
```
['Design', 'Ordered Set', 'C++']