TWO Map Easy Solution✔✔ 
IntuitionThe problem requires efficiently updating and retrieving indices based on assigned numbers. Using a combination of a map<int, int> to track index-to-nu
# Intuition
The problem requires efficiently updating and retrieving indices based on assigned numbers. Using a combination of a `map<int, int>` to track index-to-number mapping and a `map<int, set<int>>` to maintain sorted indices for each number ensures quick updates and retrievals.

# Approach
- Use `mp` to store the mapping of indices to their assigned numbers.
- Use `mpp` to store a mapping of numbers to a set of indices where they appear.
- In `change()`, update the mappings, removing previous associations if needed.
- In `find()`, return the smallest index associated with a given number.

# Complexity
- **Time complexity**:
  - `change()`: $$O(\log n)$$ due to insertion and deletion operations in `set`.
  - `find()`: $$O(1)$$ for lookup and retrieval.

- **Space complexity**:
  - $$O(n)$$ to store the mappings.

# Code
```cpp []
class NumberContainers {
public:
    map<int, int> mp;
    map<int, set<int>> mpp;
    
    NumberContainers() {}

    void change(int index, int number) {
        if(mp.find(index) != mp.end() && mp[index] != number) {
            mpp[mp[index]].erase(index);  
            if(mpp[mp[index]].empty()) {
                mpp.erase(mp[index]);
            }
        }
        mp[index] = number;
        mpp[number].insert(index);
    }

    int find(int number) {
        return mpp[number].empty() ? -1 : *mpp[number].begin();
    }
};
```
```Java []
import java.util.*;

class NumberContainers {
    private Map<Integer, Integer> mp;
    private Map<Integer, TreeSet<Integer>> mpp;

    public NumberContainers() {
        mp = new HashMap<>();
        mpp = new HashMap<>();
    }

    public void change(int index, int number) {
        if (mp.containsKey(index) && mp.get(index) != number) {
            mpp.get(mp.get(index)).remove(index);
            if (mpp.get(mp.get(index)).isEmpty()) {
                mpp.remove(mp.get(index));
            }
        }
        mp.put(index, number);
        mpp.computeIfAbsent(number, k -> new TreeSet<>()).add(index);
    }

    public int find(int number) {
        return mpp.containsKey(number) && !mpp.get(number).isEmpty() ? mpp.get(number).first() : -1;
    }
}

```
```Python []
from collections import defaultdict
import bisect

class NumberContainers:
    def __init__(self):
        self.mp = {}
        self.mpp = defaultdict(list)

    def change(self, index: int, number: int) -> None:
        if index in self.mp and self.mp[index] != number:
            self.mpp[self.mp[index]].remove(index)
            if not self.mpp[self.mp[index]]:
                del self.mpp[self.mp[index]]
        
        self.mp[index] = number
        bisect.insort(self.mpp[number], index)

    def find(self, number: int) -> int:
        return self.mpp[number][0] if self.mpp[number] else -1

```
['Hash Table', 'Ordered Set', 'Python', 'C++', 'Java', 'Python3']