Consider a keyboard where the
and so on, with
The distance between two coordinates
You are given a string word. You start with two fingers placed at any position on the keyboard at no initial cost. Moving a finger from its current letter position to a new letter position incurs a cost equal to the distance between the two letters.
Return the minimum total distance required to type all the characters in word in order.
Constraints:
word.length
word consists of uppercase English letters.
Consider a keyboard where the
and so on, with
The distance between two coordinates
You are given a string word. You start with two fingers placed at any position on the keyboard at no initial cost. Moving a finger from its current letter position to a new letter position incurs a cost equal to the distance between the two letters.
Return the minimum total distance required to type all the characters in word in order.
Constraints:
word.length
word consists of uppercase English letters.