The Question is unclear- could you please explain the question?
Mike and HashTrick Java
Hi,
see everytime when a number repeats, it is given a new hash value which is equal to the number of distinct numbers occurred till now. So we have to just store the last occurrences of all the numbers and assign the values incrementally, in ascending order of the positions of their last occurrences.
It is giving a timed out error despite a linear time complexity. Lemme know where I’m mistaken
Hi,
see what you have to do in this question is make a hashmap and a arraylist now when you go to each element in the given array you will first check that whether your arraylist contains that element if not simply put that element in the map with its value as the index of the element else put that element in the arraylist too.Next you have to just sort your arraylist according to the values of that elements in the hashmap.
Hi @justformyntra8
as you are not responding to the doubt I am marking your doubt as resolved for now. Re-open it if required.
Please mark your doubts as resolved in your course’s “Ask Doubt” section, when your doubt is resolved.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.