Loading
Loading
A theatre has seats numbered 1 to n. The check-in log seats has exactly n entries, each a seat number from 1 to n, but a scanning fault recorded some seats more than once — so other seats never appear.
Return the seat numbers that never appear, in increasing order. If every seat appears, return an empty array (the output line is blank).
seats = [4, 2, 2, 6, 1, 6][4, 2, 2, 6, 1, 6]send each number to index number − 1[1, 2, 2, 4, 6, 6]after placement: index 2 holds 2, index 4 holds 6scanindices 2 and 4 are not home, so seats 3 and 5 are missing[3, 5]Sign in to keep a note here. It is free, and nobody else can see it.
Sign inExample 1
Sign in to open hints.
Struggling is where the learning happens. Open this once you have genuinely tried, or once the hints have run out.
O(n) time · O(1) space
Input. Run your code to watch it work on this input, one line at a time.
Running code is turned off on this deployment. You can still read the problem, write code, use hints and the visualizer.
Tab moves focus out of the editor. Press Ctrl+M to let Tab indent instead.
No results yet
Run your code against the sample tests, or submit to run the full suite.
Seats 3 and 5 never appear in the check-in log.
Example 2
Both seats are filled, so the output line is empty.