반응형
시간 복잡도: O(B-A) --> 50%의 정답률
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A, B, K):
# write your code in Python 3.6
# step 1 - input A,B,K
# already succeed
# step 2 - do the for sentence
return_value = 0
for i in range(A,B+1):
if i % K == 0:
return_value += 1
return return_value
pass
시간 복잡도: O(1) --> 100%의 정답률
# you can write to stdout for debugging purposes, e.g.
# print("this is a debug message")
def solution(A, B, K):
# write your code in Python 3.6
start_num = A/K
end_num = int(B/K)
if start_num%1 != 0:
start_num = int(start_num) + 1
else:
start_num = int(start_num)
return end_num - (start_num-1)
pass
반응형
'Codility' 카테고리의 다른 글
Codility - MinAvgTwoSlice (0) | 2020.04.19 |
---|---|
Codility - GenomicRangeQuery (0) | 2020.04.19 |
Codility - PermCheck (0) | 2020.04.18 |
Codility - MissingInteger (0) | 2020.04.17 |
Codility - MaxCounters (0) | 2020.04.15 |