Mike abd HashTrick


why my code fail in other test casees except 1

hello @Pranav7g

u need to print ur vector instead of map, by sorting it on the basis of last occurence.

refer this->

TLE in Testcase 5 in your code

use unordered map in place of map

and i can’t understand how compare function work

map is storing the last occurence of number right?

bool compare(int a,int b)
{
	return m[a]<m[b]; //we sort the vector in acc. to the its value of the map,in inc. order
}

this comparator is just ordering elements in ascending order of their last occurence.

ooook thnks :innocent: