Not able to reduce complexity

help me to reduce complexity

sir this is the code and i am not able to find why does is give tle

hello @singh.pankhil40

if u observe the given hash function then u will find that 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.

concept video->