삽질의 현장 함께 해봅시다
def solution(A):
max_num = 0
for i in A:
max_num = max(max_num, i)
compare_set = set([i for i in range(1, max_num + 1)])
a_set = set(A)
compare_list = list(compare_set - a_set)
if compare_list:
return max(compare_list)
elif max_num > 0:
return max_num + 1
else:
return 1
def solution(A):
max_num = 0
for i in A:
max_num = max(max_num, i)
compare_set = set([i for i in range(1, max_num + 1)])
a_set = set(A)
compare_list = list(compare_set - a_set)
if compare_list:
return min(compare_list)
elif max_num > 0:
return max_num + 1
else:
return 1
def solution(A):
max_num = 0
for i in A:
max_num = max(max_num, i)
compare_set = set([i for i in range(1, max_num + 1)])
a_set = set(A)
compare_list = sorted(list(compare_set - a_set))
if compare_list:
return compare_list[0]
elif max_num > 0:
return max_num + 1
else:
return 1
def solution(A):
sorted_A = sorted(A)
length_A = len(A)
for i, num in enumerate(sorted_A):
if i+1 < length_A:
if sorted_A[i+1] > num + 1:
if num + 1 > 0:
return num + 1
if sorted_A[0] >= 1:
return sorted_A.pop() + 1
else:
return 1
def solution(A):
sorted_A = sorted(A)
length_A = len(A)
if length_A == 1 and A[0] != 1:
return 1
for i, num in enumerate(sorted_A):
if i+1 < length_A:
if sorted_A[i+1] > num + 1:
if num + 1 > 0:
return num + 1
if sorted_A[0] >= 1:
return sorted_A.pop() + 1
else:
return 1
import collections
def solution(A):
max_num = -1
count_dict = collections.defaultdict(int)
for i in A:
max_num = max(i, max_num)
count_dict[i] += 1
for j in range(1, max_num + 1):
if count_dict[j] == 0:
return j
if max_num <= 0:
return 1
else:
return max_num + 1
멍청이...