98일차 - Number Zoo Patrol

----------------------------------------- Failed My Solution --------------------------------------

def find_missing_number(numbers):
    result = 0
    for i in range(1, max(numbers) + 1):
        if i not in numbers:
            result = i
    if result == 0:
        result = max(numbers) + 1
    return result

------------------------------------------ Other's Solution ---------------------------------------

def find_missing_number(numbers):
    n = len(numbers) + 1
    return n * (n + 1) // 2 - sum(numbers)

좋은 웹페이지 즐겨찾기