BudiBadu Logo
00:00

Missing Seat Number

Array Easy 0 views

Imagine a small theater where each seat is tagged with an integer starting from 0, forming a neat sequence: 0, 1, 2, and so on. On a busy evening, a group of friends arrives, each holding a ticket that specifies their seat. When everyone files in, one seat remains oddly vacant. Your task is to determine which seat number is missing from the list of tickets. The array you are given represents the seat numbers that were actually scanned at the entrance, but it is missing exactly one label from the complete range.

This puzzle asks you to reconstruct the full picture from partial evidence. The seats in the range from 0 to n all exist, and only one is absent. Some sequences may begin with a missing 0, while others might lack the final seat labeled n. The array can appear in any order because people check in randomly. Your role is to think like the usher comparing the guest list to the actual arrivals, spotting the absent name at a glance.

When the array is empty, the missing seat must be 0. If every seat is accounted for in numerical order, your answer is the next seat that would extend the range. The challenge celebrates careful observation: by reconciling the tickets with the complete set of seat labels, you reveal the precise number that has slipped away unnoticed.

Example 1:

Input: nums = [3,0,1]
Output: 2
Explanation: Seats 0 through 3 exist, and 2 is the missing label.

Example 2:

Input: nums = [0,1]
Output: 2
Explanation: The full range is 0, 1, 2; the last seat is missing.

Example 3:

Input: nums = [9,6,4,2,3,5,7,0,1]
Output: 8
Explanation: Among seats 0 through 9, the label 8 never appears.

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.

BudiBadu Logo

Missing Seat Number

Array Easy 0 views

Imagine a small theater where each seat is tagged with an integer starting from 0, forming a neat sequence: 0, 1, 2, and so on. On a busy evening, a group of friends arrives, each holding a ticket that specifies their seat. When everyone files in, one seat remains oddly vacant. Your task is to determine which seat number is missing from the list of tickets. The array you are given represents the seat numbers that were actually scanned at the entrance, but it is missing exactly one label from the complete range.

This puzzle asks you to reconstruct the full picture from partial evidence. The seats in the range from 0 to n all exist, and only one is absent. Some sequences may begin with a missing 0, while others might lack the final seat labeled n. The array can appear in any order because people check in randomly. Your role is to think like the usher comparing the guest list to the actual arrivals, spotting the absent name at a glance.

When the array is empty, the missing seat must be 0. If every seat is accounted for in numerical order, your answer is the next seat that would extend the range. The challenge celebrates careful observation: by reconciling the tickets with the complete set of seat labels, you reveal the precise number that has slipped away unnoticed.

Example 1:

Input: nums = [3,0,1]
Output: 2
Explanation: Seats 0 through 3 exist, and 2 is the missing label.

Example 2:

Input: nums = [0,1]
Output: 2
Explanation: The full range is 0, 1, 2; the last seat is missing.

Example 3:

Input: nums = [9,6,4,2,3,5,7,0,1]
Output: 8
Explanation: Among seats 0 through 9, the label 8 never appears.

00:00
Loading editor...
Test Results

Run your code to see test results

Click the Submit button to execute your solution

Related Problems

No related problems found

Comments (0)

Join the Discussion

Share your thoughts, ask questions, or help others with this problem.