class Solution:
def calculateTime(self, keyboard: str, word: str) -> int:
order={}
for i in range(len(keyboard)):
order[keyboard[i]]=i
ans=abs(0-order[word[0]])
for i in range(len(word)-1):
ans+=abs(order[word[i]]-order[word[i+1]])
return ans
'알고리즘 문제 > Leetcode' 카테고리의 다른 글
1822. Sign of the Product of an Array (0) | 2023.04.02 |
---|---|
884. Uncommon Words from Two Sentences (0) | 2023.04.02 |
762. Prime Number of Set Bits in Binary Representation (0) | 2023.04.02 |
2006. Count Number of Pairs With Absolute Difference K (0) | 2023.04.02 |
559. Maximum Depth of N-ary Tree (0) | 2023.04.02 |