Problem intuition
Because duplicates are adjacent in a sorted array, you only need to track the next slot for a new unique value.
A non-optimal solution can still be correct by writing into a helper structure first, but the clean version reuses the array in place.
Java solution ladder
The solutions below are ordered from least optimal to most optimal, so you can see the improvement path instead of only the final answer.