https://app.codility.com/demo/results/trainingYMXCBY-VNE/
Point
- center point까지 start와 end를 반복문을 통해 비교해간다
Tip
Task Score
100%
Correctness
100%
Performance
100%
Detected time complexity
O(length(S))
def solution(S):
if len(S)%2 == 0:
return -1
mid = len(S)//2
start = 0
end = -1
while start < mid:
if S[start] != S[end]:
return -1
start += 1
end -= 1
return mid
문제를 푸는데 도움이 된 테스트 케이스
728x90
반응형
'Problem Solving > Codility' 카테고리의 다른 글
[Python] LongestPassword (0) | 2021.07.18 |
---|---|
[Python] TreeHeight (0) | 2021.07.18 |
[Python] FirstUnique (0) | 2021.07.15 |
[Python] DisappearingPairs (0) | 2021.07.15 |
[Python] 8.1. Dominator (0) | 2021.04.05 |
댓글