I am getting wrong answer in test cases . Kindly tell what mistake exists in my code. Code:
Mike and Hashtrick
@Puneet_Sharma
Their is a better approach nLog(n).
We know every time a number repeats, it is given a new hash value, which is equal to the number of distinct numbers occurred till now. So we can just store the last occurrences of all the numbers and assign the values incrementally, in increasing order of the positions of their last occurrences.
refer to this code : https://ide.codingblocks.com/s/213536