Loading...
Loading...
Loading...
A warehouse system receives a list of order ids. Print YES if some id appears more than once, otherwise NO. Comparing every pair is too slow for a long list.
Example 1
Input
5 4 8 15 16 23
Output
NO
Example 2
Input
6 9 8 7 6 5 9
Output
YES
Try the problem first. Open one hint at a time.
A pair loop does about n² / 2 comparisons, far too many for n = 200000.
A set holds each id once. If the set is smaller than the list, something repeated.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor