Minimum Number of Pushes to Type Word II
You are given a string word containing lowercase English letters.
Telephone keypads have keys mapped with distinct collections of lowercase English letters, which can be used to form words by pushing them. For example, if key 2 is mapped with ["a", "b", "c"], you need to push the key one time to type "a", two times to type "b", and three times to type "c".
It is allowed to remap the keys numbered 2 to 9 to distinct collections of letters. The keys can be remapped to any amount of letters, but each letter must be mapped to exactly one key.
Return the minimum number of pushes needed to type word after remapping the keys.
Note that 1, *, #, and 0 do not map to any letters.
word = "abcde"5word = "xyzxyzxyzxyz"12x, y, and z can each be mapped to require one push, and each appears four times, so the total cost is 12.Constraints
- 1 <= word.length <= 10^5
- word consists of lowercase English letters.