2 through 9. Each key holds its own group of letters: one press gives the first letter of the group, two presses give the second, and so on.
You are free to redistribute the letters among the keys: every letter must land on exactly one key at some position in its group, and a key may hold any number of letters (or none). Keys 0, 1, * and # carry no letters.
Given a string text of lowercase English letters, choose a layout that makes typing text take as few presses as possible, and return that number.text="banana" → 6
Each of the three letters goes first on its own key: 3 + 2 + 1 = 6.
text="abcdefghij" → 12
Eight letters go first on the eight keys, the other two go second: 8·1 + 2·2 = 12.
text="qqqq" → 4
text consists of lowercase English letterstext="banana"
6
Run checks the first 3 tests in your browser. Submit checks all 50 tests on the server, hidden ones included.