Search⌘ K
AI Features

Solution: Minimum Number of Pushes to Type Word II

Understand how to calculate the minimum number of pushes needed to type a word on a phone keypad by tracking letter frequency and assigning keys optimally. This lesson teaches you to implement an efficient solution that remaps letters to keys to minimize key presses, using sorting and frequency counting techniques.

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 ...