LeetCode solutions

2088. Minimum Time to Type Word Using Special Typewriter

My accepted Python solution to LeetCode problem 2088, Minimum Time to Type Word Using Special Typewriter, running in 0ms.

  • Difficulty: Easy
  • Python
  • Runtime 0ms
  • Memory 17.2MB

Read the problem on LeetCode View on GitHub

Python

Accepted on LeetCode — runtime 0ms, memory 17.2MB, accepted 2026-01-02.

python
class Solution:
    def minTimeToType(self, word: str) -> int:
        curr = ord('a')
        time = 0
        for c in word:
            diff = abs(ord(c) - curr)
            time += min(diff, 26 - diff) + 1
            curr = ord(c)
        return time

Source