beat 100% c++ 
IntuitionThe problem requires efficient updates and retrieval of the smallest index corresponding to a number. A map-based approach allows fast updates and effi
# Intuition
The problem requires efficient updates and retrieval of the smallest index corresponding to a number. A map-based approach allows fast updates and efficient retrieval.
# Approach
1) Data Structures Used:

* hm (map<int, int>): Maps an index to its currently assigned number.
* mp (map<int, set<int>>): Maps a number to a sorted set of indices where it appears.
2) Operations:

* change(index, number):
* If the index already has a number assigned:
* Remove it from the previous number's set in mp.
* Update the mapping hm[index] = number.
* Insert index into the corresponding mp[number] set.
3) find(number):
* If number exists in mp and has at least one index, return the smallest index (begin() of set).
Otherwise, return -1.
# Complexity
- Time complexity:
O(log n)
- Space complexity:
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```cpp []
class NumberContainers {
public:
 map<int,int> hm;
    map<int,set<int>> mp;

    
    
    NumberContainers() {
        
    }
    
    void change(int index, int number) {
        
     if(hm.count(index)!=0){
         int a = hm[index];
         
       
        set<int>::iterator it;
         
         it = mp[a].find(index);
         mp[a].erase(it);
       
         
        
         hm[index]= number;
         
         if(mp.count(number)!=0 && mp[number].size()!=0){
             
             mp[number].insert(index);
        
         }
         else{
             set<int> st ;
             st.insert(index);
             mp[number] = st;
         }
         
     }
        else{
            
            hm[index] = number;
               if(mp.count(number)!=0){
             
             mp[number].insert(index);
        
         }
         else{
             set<int> st ;
             st.insert(index);
             mp[number] = st;
         }
            
        }
        
        
        
    }
    
    
    
    int find(int number) {
        
       if(mp.count(number)!=0 && mp[number].size()!=0){
           
           return *mp[number].begin();
       }
        
        return -1;

    }
};


```
['C++']