Very Simple Java/C++/Python Solution Using ( map and treeSet )
IntuitionApproach
Create a map1 of number to indexes (the indexes are to be stored in sorted way so we use TreeSet( tree set is just set but it stores values in
# Intuition
<!-- Describe your first thoughts on how to solve this problem. -->

# Approach
<!-- Describe your approach to solving the problem. -->
1. Create a **map1 of number to indexes** (the **indexes are to be stored in sorted way so we use TreeSet**( tree set is just set but it stores values in sorted behaviour )).
2. Create another map2 for indexes to check if a index already exist in our number:index map1.
3. in case the index is present we modify the map1 ( removing that index from number in the map of number:indexes )
4. we also put the number:index each time in change function
5. we fetch the first value from the number:index map during find if it is present.
# Complexity
- Time complexity:O(n*logn) {logn is for change and n is the number of ops}
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

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

# Code
```java []
class NumberContainers {
    Map<Integer, TreeSet<Integer>> map;
    Map<Integer, Integer> indexMap;
    public NumberContainers() {
        map = new HashMap<>();
        indexMap = new HashMap<>();
    }
    public void change(int index, int number) {
        if (indexMap.containsKey(index)) {
            int prevNumber = indexMap.get(index);
            if (map.containsKey(prevNumber)) {
                map.get(prevNumber).remove(index);
                if (map.get(prevNumber).isEmpty()) {
                    map.remove(prevNumber);
                }
            }
        }
        indexMap.put(index, number);
        map.putIfAbsent(number, new TreeSet<>());
        map.get(number).add(index);
    }
    public int find(int number) {
        return map.containsKey(number) && !map.get(number).isEmpty() ? map.get(number).first() : -1;
    }
}
```
```C++ []
class NumberContainers {
public:
    NumberContainers() {}
    std::unordered_map<int, std::set<int>> map;
    std::unordered_map<int, int> indexMap;
    
    void change(int index, int number) {
        if (indexMap.count(index)) {
            int prevNumber = indexMap[index];
            map[prevNumber].erase(index);
            if (map[prevNumber].empty()) {
                map.erase(prevNumber);
            }
        }
        indexMap[index] = number;
        map[number].insert(index);
    }

    int find(int number) {
        return map.count(number) && !map[number].empty() ? *map[number].begin() : -1;
    }
};
```
```Python3 []
class NumberContainers:

    def __init__(self):
        self.map = defaultdict(sortedcontainers.SortedSet)
        self.indexMap = {}

    def change(self, index: int, number: int) -> None:
        if index in self.indexMap:
            prevNumber = self.indexMap[index]
            self.map[prevNumber].discard(index)
            if not self.map[prevNumber]:
                del self.map[prevNumber]
        self.indexMap[index] = number
        self.map[number].add(index)

    def find(self, number: int) -> int:
        return next(iter(self.map[number]), -1) if number in self.map else -1
```
['Hash Table', 'Sorting', 'C++', 'Java', 'Python3']