#100easyBit Manipulation
Missing Instrument ID
Time Limit: 2sMemory: 256MB
Problem
An exchange assigns sequential instrument IDs from 0 to n-1. Due to a data corruption event, one ID is missing from the records. Given n (the total count of instruments) and the n-1 IDs that remain, find the missing instrument ID.
Input Format
- Line 1: integer
n(total instruments including the missing one). - Line 2:
n-1space-separated integers — the remaining IDs.
Output Format
A single integer — the missing ID.
Examples
Example 1
Input(Line 1: integer n (total instruments including the missing one).)
4 3 0 1
Output
2
Range is [0,3]. Array has {0,1,3}. Missing: 2.
Example 2
Input(Line 1: integer n (total instruments including the missing one).)
3 0 1
Output
2
Range is [0,2]. Array has {0,1}. Missing: 2.
Constraints
- •1 ≤ n ≤ 10^4
- •Array contains n-1 distinct integers from range [0, n-1] (one missing)
Loading interactive editor…