+ 1
Duplicate remover not working properly.
3 Respostas
+ 1
You're accessing the same array which you are iterating based on its index. So, if you erase one element and reduce the size, you fulfill the stop condition, but you'll also skip one element:
122322
Erase x = 1, new array 12322
Next x = 2, value 3
Next x = 3, value 2
Erase x = 3, new array 1232
Next x = 4 < size
So you are missing the number of elements, which you reduced the size for at the end of each array.
+ 2
See here, a possible solution:
https://code.sololearn.com/cZy6Kj8iqLU7/?ref=app
+ 1
Sandra Meyer thanks for pointing out the error. That helped me to come up with a solution:
https://code.sololearn.com/c2968L8hLXCc/?ref=app