Smallest Missing Number
Given a list of numbers, write a program to print the smallest positive integer missing in the given numbers. Input-The input will be a single line containing numbers separated by space. Output-The output should be a single line containing the smallest missing number from given numbers. Explanation-For example, if the input numbers are 3, 1, 2, 5, 3, 7, 7.
The number 1, 2, 3 are present. But the number 4 is not. So 4 is the smallest positive integers that is missing from the given numbers.
List = "3 1 2 5 3 7 7"
print(List)
NumStr = List.split(' ')
ListInt = [int(number) for number in NumStr]
Missing_Num = 1
while True:
if Missing_Num not in ListInt:
break
Missing_Num += 1
print('The smallest missing number is: ')
print(Missing_Num)
Comments
Leave a comment