Really bad question

Question statement talks about “modifying original array” although it doesn’t even look at that. What it does, it takes returned length, and then it trims original array to returned length. It doesn’t verify correctness of array, it doesn’t do anything with that!
Hence, if you pack in front of array all the unique values and later you’ll return expected length, test will “verify” this by itself.
Really stupid question!

I don’t know which language you are using but in C++ A.resize() can easily trim the array so you just need to make sure you’re moving the unique elements to the front.

Click here to start solving coding interview questions