Answer to Question #234022 in Python for rasi

Question #234022

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.

input-1: 3 1 2 5 3 7 7

output-1:4

input-2: 5 5 2 3 1 8 8 4

output-2:6


1
Expert's answer
2021-09-07T18:14:06-0400
if __name__ == '__main__':
    numbers = [int(x) for x in input().split(' ')]
    unique_numbers = set(numbers)
    for i in range(1, len(numbers) + 2):
        if i not in unique_numbers:
            print(i)
            break

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS