A festival's entry gate scans every attendee's wristband serial number as they walk in. Security wants an automatic alert if the same serial number is ever scanned twice in a single day, since that would indicate a duplicated or counterfeit wristband being reused.
Given the sequence of serial numbers scanned during the day, determine whether any serial number appears more than once.
Line 1: an integer n, the number of scans.
Line 2: n space-separated integers, the scanned serial numbers in the order they were recorded.
Print YES if some serial number was scanned more than once, otherwise print NO.
Example 1
Input
4 1 2 3 1
Expected
YES
Explanation
Serial number 1 is scanned at the first and fourth positions, so a duplicate exists and the answer is YES.
Example 2
Input
4 1 2 3 4
Expected
NO
Explanation
All four serial numbers are distinct, so no wristband was reused and the answer is NO.
Ready to solve this?
Sign in to open the editor, run your code against the sample tests, and submit against the full test suite.
Sign in to solve →