Mike and hashtrick approach

mike and hashtricks hashing question how to approach this question . I am unable to figure out what to do in this question

@Khushboo please give me some hint

Hi Neeraj, here is the hint:
We know everytime 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.

2 Likes

@Khushboo can you please explain it with some input and output data? Thanks.

1 Like