k-th on its button, you press that button k times in a row.
You are given a string text. The layout is chosen once, and then the whole text is typed on it. Return the smallest possible total number of presses.text="tomato" → 6
There are only four distinct letters, so each can sit first on its own button. Six letters, six presses.
text="abcdefghijj" → 12
There are ten distinct letters. j appears twice, so it goes first on a button (2 presses). Eight more letters are also first (8 presses), and the last one has to sit second on some button (2 presses). Total: 12.
text consists of lowercase English letterstext="tomato"
6
Run checks the first 3 tests in your browser. Submit checks all 78 tests on the server, hidden ones included.