Print the missing number from 1 to 10 in an array
Problem to print the missing number from 1 to 10 in an array.
Example-1:
Input : n = [ 5, 6, 9, 4, 10] Output : [1,2,3,7,8] Explain : The missing number from 1 to 10 are (1,2,3,7,8).
Example-2:
Input : n = [ 1, 3, 4, 6, 7, 8] Output : [2,5,9,10] Explain : The missing number from 1 to 10 are (2,5,9,10).
Solution
n = [ 5, 6, 9, 4, 10] l = [] for i in range(1,11): if(i not in n): l.append(i) print(l)
Output
[1,2,3,7,8]