반응형
시간 복잡도: O(N) or O(N * log(N)) --> 77%의 정답률 (Wrong answer 가 있었음)
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# write your code in Python 3.6
# step 1 - input array A
# already succeed
# step 2 - find the smallest positive integer of A
# sorting A
A = sorted(A)
# find the positive integer
try:
a = A.index(1)
tmp = A[a:]
tmp = set(tmp)
except:
return 1
b = 1
for i in tmp:
if i == b:
b += 1
else:
return b
return b
pass
시간 복잡도: O(N) or O(N * log(N)) --> 100%의 정답률
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A):
# write your code in Python 3.6
# step 1 - input array A
# already succeed
# step 2 - find the smallest positive integer of A
# sorting A
A = set(A)
A = sorted(A)
# find the positive integer
try:
a = A.index(1)
tmp = A[a:]
except:
return 1
b = 1
for i in tmp:
if i == b:
b += 1
else:
return b
return b
pass
반응형
'Codility' 카테고리의 다른 글
Codility - CountDiv (0) | 2020.04.18 |
---|---|
Codility - PermCheck (0) | 2020.04.18 |
Codility - MaxCounters (0) | 2020.04.15 |
Codility - FrogRiverOne (0) | 2020.04.13 |
Codility - TapeEquilibrium (0) | 2020.04.13 |