Find Missing Number
easy⏱ 15 mintypescriptchallengesproblem-solving-basic-
Caso de ejemplo — tu programa lee de stdin e imprime en stdout.
Given an array containing n distinct numbers taken from 0, 1, 2, ..., n, find the one number that is missing from the array.
Use the sum formula: sum(0 to n) = n*(n+1)/2
Example: [3,0,1] → Missing is 2 (expected: 0,1,2,3)
Formato de entrada
Line 1: n. Line 2: n space-separated integers.
Formato de salida
The missing number.
Restricciones
1 ≤ n ≤ 10⁴