https://leetcode.com/problems/score-of-a-string/description/
1 2 3 4 5 6 7 | class Solution: def scoreOfString(self, s: str) -> int: answer = 0 for i in range(1, len(s)): answer += abs(ord(s[i]) - ord(s[i-1])) return answer | cs |
반응형
'python-algorithm' 카테고리의 다른 글
leetcode 3099. Harshad Number (0) | 2024.04.23 |
---|---|
leetcode 3046. Split the Array (0) | 2024.04.22 |
백준 27736 찬반투표 (0) | 2024.04.21 |
leetcode 3120. Count the Number of Special Characters I (0) | 2024.04.21 |
백준 31668 특별한 가지 (0) | 2024.04.19 |
댓글