1165. Single-Row Keyboard
Содержание
class Solution:
def calculateTime(self, keyboard: str, word: str) -> int:
pos = {c: i for i, c in enumerate(keyboard)}
res = i = 0
for c in word:
res += abs(pos[c] - i)
i = pos[c]
return res