1974. Minimum Time to Type Word Using Special Typewriter
Содержание
class Solution:
def minTimeToType(self, word: str) -> int:
res = prev = 0
for c in word:
curr = ord(c) - ord('a')
t = abs(prev - curr)
t = min(t, 26 - t)
res += t + 1
prev = curr
return res