LeetCode solutions

3379. Score of a String

My accepted Python solution to LeetCode problem 3379, Score of a String, running in 2ms.

  • Difficulty: Easy
  • Python
  • Runtime 2ms
  • Memory 17.4MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 2ms, memory 17.4MB, accepted 2026-01-01.

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

Source