Map related problem.

Revision en1, by RubayedMunna, 2022-01-15 16:50:51

I got a problem whenever I was solving Atcoder contest.

I have an array. I want to store index of every occurrences of every elements of the array so that whenever someone gives me two number x and k, I can show him/her the index of k th occurrence of x.

To do this, I used a map. I used the key value of map as elements of the given array and for mapped value I used a vector so that I can push back the occurrences of the elements to the vector(mapped value).

Now, the problem is I don't know how to push back indexes to the map of vector. I also faced problem whenever I tried to find k th occurrence of the element x.

If I'm wrong, please correct me.

Tags map, vector, map of vectors

History

 
 
 
 
Revisions
 
 
  Rev. Lang. By When Δ Comment
en1 English RubayedMunna 2022-01-15 16:50:51 692 Initial revision (published)