Practice Minimum Distance to Type a Word Using Two Fingers
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
The uppercase keyboard has rows ABCDEF, GHIJKL, MNOPQR, STUVWX, and YZ, aligned on the left. Coordinates start at (0, 0), so a letter with zero-based alphabet index q is at (q // 6, q % 6), where // means integer division. Use two fingers to type word in order. Moving a finger from (r1, c1) to (r2, c2) costs |r1 - r2| + |c1 - c2|. Initial finger positions are free and may be chosen independently. Return the minimum total movement distance.
Source: Minimum Distance to Type a Word Using Two Fingers on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
word = "CAKE"
3
# Example 2
word = "HAPPY"
6
Constraints
Related LeetCode Problems
Practice more problems similar to Minimum Distance to Type a Word Using Two Fingers.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.