Practice Minimum Number of Pushes to Type Word II
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Medium#3016
LeetCode ProblemMinimum Number of Pushes to Type Word II
Problem Statement
Map each lowercase letter to exactly one of keys 2 through 9, with any number of letters per key. A letter costs its one-based position on that key in pushes. Choose the mapping to minimize the pushes needed for word and return that total. Other keys do not type letters.
Source: Minimum Number of Pushes to Type Word II on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
word = "abcde"
Output
5
# Example 2
Input
word = "xyzxyzxyzxyz"
Output
12
# Example 3
Input
word = "aabbccddeeffgghhiiiiii"
Output
24
Constraints
1 <= word.length <= 10^5
word consists of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Minimum Number of Pushes to Type Word II.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.