A conference issues numbered badges 1 through n to its n registered attendees. At the entrance, a scanner records one badge number per person as they walk in, producing a log of exactly n readings; because of scanner glitches, some badge numbers may be logged more than once while others -- belonging to attendees who slipped past unscanned -- never appear at all. Given the log, list every badge number from 1 to n that the scanner never recorded, in increasing order.
Print the badge numbers that never appear in the log, space-separated in increasing order. If every badge number from 1 to n was scanned at least once, print an empty line.
Example 1
Input
8 4 3 2 7 8 2 3 1
Expected
5 6
Explanation
Badges 1,2,3,4,7,8 each appear at least once in the log (2 and 3 each appear twice). Badges 5 and 6 never appear anywhere in the log, so they are the ones reported, in increasing order: 5 6.
Example 2
Input
5 1 1 1 1 1
Expected
2 3 4 5
Explanation
Only badge 1 was ever scanned -- five times over. Badges 2, 3, 4 and 5 were never recorded even once, so all four are reported in increasing order: 2 3 4 5.
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 →