Interview Shuriken 53: Find the Missing Number
You are given an array containing ‘n’ distinct numbers taken from the range: [0, n]. Since the array contains only ‘n’ numbers and count of numbers from 0 to n is ‘n+1’, so, you have to find the missing number.
Example 1:
Example 2:
Input Format:
Constraints:
Output Format:
Sample Input 1:
Sample Output 1:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Read input as specified in the question. | |
## Print output as specified in the question. | |
n=int(input()) | |
arr=list(map(int,input().split())) | |
res=set(arr) | |
[print(i,end=" ") for i in range(1,n+1) if i not in res] |
Comments
Post a Comment
Please give us your valuable feedback