Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Pushes to Type Word I

med
30 min
Try to solve the Minimum Number of Pushes to Type Word I problem.

Statement

You are given a string word containing distinct lowercase English letters.

Telephone keypads have keys numbered from 22 to 99, offering 88 keys in total. You can map the letters of the English alphabet to these keys such that each letter is assigned to at most one key.

When a letter is typed, the key it is assigned to must be pressed a number of times equal to the letter’s position on that key. Specifically, the first letter placed on a key requires 11 push, the second letter requires 22 pushes, the third letter requires 33 pushes, and so forth.

Return the minimum total number of pushes required to type word after choosing an optimal key mapping.

Constraints:

  • 1≤1 \leq word.length ≤26\leq 26

  • word consists of lowercase English letters.

  • All letters in word are distinct.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Pushes to Type Word I

med
30 min
Try to solve the Minimum Number of Pushes to Type Word I problem.

Statement

You are given a string word containing distinct lowercase English letters.

Telephone keypads have keys numbered from 22 to 99, offering 88 keys in total. You can map the letters of the English alphabet to these keys such that each letter is assigned to at most one key.

When a letter is typed, the key it is assigned to must be pressed a number of times equal to the letter’s position on that key. Specifically, the first letter placed on a key requires 11 push, the second letter requires 22 pushes, the third letter requires 33 pushes, and so forth.

Return the minimum total number of pushes required to type word after choosing an optimal key mapping.

Constraints:

  • 1≤1 \leq word.length ≤26\leq 26

  • word consists of lowercase English letters.

  • All letters in word are distinct.