This is an extension of problem we have discussed in an earlier post.
...
For further actions, you may consider blocking this person and/or reporting abuse
I just made an inplace algorithm to move the duplicates replaced with zeros to the end of array, this runs in O(n) time and O(1) space, you can find the code for the same here : codepen.io/karthik19894/pen/XWWwbw...
Try running this array example int[] arr = new int[]{1,2,2,3,4,4,5,6,3, 9, 8, 7,9999}; :D
That is not the correct sample data set for this problem as problem statement specifies that input array must be sorted.
Although I realized that repl was pointing to code base of different problem.I have attached a right code base now.
Yeah I was using repl code example and just changed last element. Was pointing this out because I know some people learning Java will try stuff with the code and be confused about results.
Referring to the example above, wouldn't this give us 4 twice in the duplicates table?
you are right, I should check if item already exists inside the duplicate list. I have updated the code and attached repl.
Thanks for the feedback.