Hi @Abdul_Mateen , thank you for your explanation. Doesn’t matter what elements go after all the unique elements, that’s why [2, 11, 2, 11] and [2, 11, 2, 2] both have the same result - 2 unique elements at the beginning.
In the problem’s test cases explanation also says about removing the duplicates:
Input: [2, 2, 2, 11]
Explanation: The first two elements after removing the duplicates will be [2, 11].
The reason I asked was the line “move all duplicates at the end of the array” in the problem statement. I thought I was necessary to move all the duplicates at the end of the array as the algorithm does this sorting in place. This line may substituted with “move all unique elements to the beginning of the array” for better understanding, but it’s a subtle detail. Everything is clear for me now.