1974. Minimum Time to Type Word Using Special Typewriter - Daily Leetcode (Day 23)

preview_player
Показать описание
How's everyone doing today :)

#leetcode #dynamicprogramming #easy
Рекомендации по теме
Комментарии
Автор

class Solution:
def minTimeToType(self, word: str) -> int:
temp=len(word)
word1='a'+word
res=0

for i in range(1, len(word1)):
res=res+ min(
abs( ord(word1[i]) -ord(word1[i-1])),
26- abs( ord(word1[i]) -ord(word1[i-1]))
)
print( 'printing', res, temp)
return res+temp

hsakarp
visit shbcf.ru