Using Map and Set || Best Solution || Beats 100% both in Space and Time in CPP || Explained ||
IntuitionApproachComplexity
Time complexity:

Space complexity:
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)$$ -->

- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class NumberContainers {
public:
    unordered_map<int, int>m; // To Track the index and number associated with it
    unordered_map<int, set<int>>f; // To track the minimum index available for a number
    NumberContainers() {
        m[-1] = 0; // Initializing ,,can be skipped ...Since m and have a global
                   // scope
        f[-1].insert(0);
    }

    void change(int index, int number) {
        if (m.find(index) != m.end()) { // If already exists
            if (m[index] == number) {
                return;
            } else {
                f[m[index]].erase(index);
            } // Updation
        }
        m[index] = number;
        f[number].insert(index);
    }

    int find(int number) {
        if (f.find(number) != f.end()) {
            if (f[number].empty()) {
                return -1;
            } // If the number doesnot contain any index return -1
            return *(f[number].begin());
        }
        return -1;
    }
    // Time Complexity:O(N)
    // Space Conplexity:O(N)
};

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