Missing Number

View as PDF

Submit solution


Points: 10 (partial)
Time limit: 1.0s
Memory limit: 32M

Author:
Problem type
Allowed languages
Python

Given an array nums containing n distinct integers in the range [0, n], output the only integer in the range that is missing from the array. Note that if n is the missing integer, then all integers in the range [0, n-1] will be present in the array, and the output should be n.

Input Specification

The first line of the input gives the number of test cases, T, and then T test cases follow.

For each test case, it will consist of one lines contains n integers separated by spaces.

Constraints

1 \leq T \leq 100

1 \leq n \leq 100

Output Specification

For each test case, output one line containing Case #x: y, where x is the case number(starting from 1), and y is the missing number of the given input array.

Sample Input

2
3 0 1
0 1

Sample Output

Case #1: 2
Case #2: 2

Hint

sort loop if-else

Reference

https://leetcode.com/problems/missing-number/


Comments

There are no comments at the moment.