본문 바로가기

IT/코딩테스트

[Leetcode] 3110. Score of a String

728x90

https://leetcode.com/problems/score-of-a-string

class Solution:
    def scoreOfString(self, s: str) -> int:
        sum = 0
        for i in range(len(s)-1):
            sum += abs(ord(s[i]) - ord(s[i+1]))
        return sum
728x90