السابق التالي
0 / 21
الوحدة النمطية DEMO-32-106DEMO-C-32

Find Missing Number

DEMO-C-32 • Programming in C

Browser-only practice

بيان المشكلة

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

قيود

n <= 100

تنسيق الإدخال

n and n-1 integers

تنسيق الإخراج

Missing number

حالات اختبار نموذجية

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

العينة رقم 1
عينة ظاهرة
5
1 2 4 5
3
Sum 1..5 = 15. Array sum=12. Missing 3.
العينة رقم 2
عينة ظاهرة
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
إعدادات المحرر