educative.io

Educative

Incorrect if number repeats more than twice

for [1,2,2,1,1]
Expected Output = [1,2]
Actual Output = [2,1,1]

1 Like

noticed this as well

wondering how to modify algorithm to solve this one

1 Like

I would just store the solutions as a set and then copy it into the List/return it.

Unless the course material has been changed after you guys posted, the problem actually states specifically that some numbers appear twice. So repeating more than twice is out of scope for this one.

1 Like