Tap here to switch tabs
Problem
Ask
Submissions

Problem: Minimum Number of Pushes to Type Word II

med
30 min
Explore how to determine the minimum number of key pushes required to type a given word using a custom letter-to-key mapping on a phone keypad. Understand the problem constraints and learn strategies for optimizing keypad remapping to minimize typing effort.

Statement

The keys (numbered 22 to 99) on a telephone keypad are associated with specific groups of lowercase English letters. Below is an example of how letters can be mapped to keys on a telephone keypad.

Note: The keys 11, *, 00, and #\# do not map to any letters.

In the above mapping, the key 22 is mapped with letters ["a", "b", "c"]; pressing it once types "a", pressing it twice types "b", and pressing it three times types "c".

Any mapping is possible as long as each letter is assigned to exactly one key, and keys can be mapped to any number of distinct letters.

Given a string, word, consisting of lowercase English letters, return the minimum number of pushes needed to type it after remapping the keys.

Note: No mapping is provided in the input. You can devise any mapping if needed.

Constraints:

  • 11 \leq word.length 103\leq 10^3

  • word consists of only lowercase English letters.

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Minimum Number of Pushes to Type Word II

med
30 min
Explore how to determine the minimum number of key pushes required to type a given word using a custom letter-to-key mapping on a phone keypad. Understand the problem constraints and learn strategies for optimizing keypad remapping to minimize typing effort.

Statement

The keys (numbered 22 to 99) on a telephone keypad are associated with specific groups of lowercase English letters. Below is an example of how letters can be mapped to keys on a telephone keypad.

Note: The keys 11, *, 00, and #\# do not map to any letters.

In the above mapping, the key 22 is mapped with letters ["a", "b", "c"]; pressing it once types "a", pressing it twice types "b", and pressing it three times types "c".

Any mapping is possible as long as each letter is assigned to exactly one key, and keys can be mapped to any number of distinct letters.

Given a string, word, consisting of lowercase English letters, return the minimum number of pushes needed to type it after remapping the keys.

Note: No mapping is provided in the input. You can devise any mapping if needed.

Constraints:

  • 11 \leq word.length 103\leq 10^3

  • word consists of only lowercase English letters.