Input: [1,1,1,2] Output: [1,1,1] Expected: [1,1,2] Can someone explain this testcase to me?
Input: [1,1,1,2] Output: [1,1,1] Expected: [1,1,2] Can someone explain this testcase to me?

@hangdu it can duplicate twice. So you can image that input => 1, 1, 1, 2 and final array would become 1, 1, 2, 2. The output (length) is 3. That's why expected result is 1, 1, 2.