A dormitory maintenance team is auditing a bank of n lockers, numbered from 1 to n. Over the course of the day, staff performed exactly n locker checks, each recorded as the number of the locker visited. Because a locker can be checked more than once while another locker might not be checked at all, the log may contain duplicates and gaps. Help the team figure out exactly which lockers were never checked, so someone can be sent to inspect them before the day ends.
Line 1: an integer n -- the number of lockers (and the number of log entries). Line 2: n integers c_1 c_2 ... c_n -- the log of checks, each satisfying 1 <= c_i <= n.
Print the locker numbers that were never checked, in strictly increasing order, space separated on one line. If every locker was checked at least once, print an empty line.
1 <= n <= 100000 1 <= c_i <= n
Example 1
Input
5 1 1 3 3 5
Expected
2 4
Explanation
There are 5 lockers. The log shows locker 1 checked twice, locker 3 checked twice, and locker 5 checked once. Lockers 2 and 4 never appear anywhere in the log, so they are the missing ones, printed in increasing order.
Example 2
Input
4 1 2 3 4
Expected
(empty)Explanation
Every locker number from 1 to 4 appears exactly once in the log, so no locker is missing and an empty line is printed.
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 →