Solution works even if duplicated are not removed from array

I tried to solve the problem the way it is mentioned in the problem statement, but it gave me TLE then i solved it without actually removing duplicates from the list and it worked.

are you sure ?, because it does not work for me, and even when I am testing custom input it is looking for the array elements instead of length.

Click here to start solving coding interview questions