Previous Next
0 / 21
Module DEMO-32-106DEMO-C-32

Find Missing Number

DEMO-C-32 โ€ข Programming in C

Browser-only practice

Problem Statement

Given an array containing n-1 distinct numbers taken from the range 1 to n, find the missing number. Input the value of n (the range limit, making the array size n-1) and then the array elements.

Example

Input:

5 1 2 4 5

Output:

3

Constraints

n <= 100

Input Format

n and n-1 integers

Output Format

Missing number

Sample Testcases

Submit runs every public testcase in this browser. Results and code never leave this device.

Sample #1
Public sample
5
1 2 4 5
3
Sum 1..5 = 15. Array sum=12. Missing 3.
Sample #2
Public sample
3
2 3
1
Missing 1.

Web terminal

C, C++, Java, and Python run locally in a browser VM. No worker or visualizer is used.

Saved in this browser
Editor settings