I recently found out that inserting a vector in a map is possible : ↵
↵
~~~~~↵
map< vector<int>, int > mp;↵
vector<int> vec = {1,2,3,4,5};↵
mp[vec] = 5;↵
cout<<mp[vec];↵
// prints 5↵
~~~~~↵
1. If there are ``N`` vectors in mp present as keys already, what is the time complexity to insert a new vector of size ``M`` in mp ? ↵
Is it ``O(M*log(N)`` or something else depending upon the sizes of vectors present in mp already ?↵
2. What would be the time complexity of a query operation such as mp[vec] ? ↵
Please help.
↵
~~~~~↵
map< vector<int>, int > mp;↵
vector<int> vec = {1,2,3,4,5};↵
mp[vec] = 5;↵
cout<<mp[vec];↵
// prints 5↵
~~~~~↵
1. If there are ``N`` vectors in mp present as keys already, what is the time complexity to insert a new vector of size ``M`` in mp ? ↵
Is it ``O(M*log(N)`` or something else depending upon the sizes of vectors present in mp already
2. What would be the time complexity of a query operation such as mp[vec]
Please help.