2 to 9: if a key holds several letters, the first takes one tap, the second two taps, the third three, and so on.
You get to decide which letters go on which keys and in what order. Each letter must sit on exactly one key, and a key may hold any number of letters.
Given a string word of distinct lowercase English letters, return the fewest total taps needed to type it with the best layout.word="plan" → 4
Each of the four letters can go first on its own key, one tap each.
word="abcdefghij" → 12
Eight letters take the first slot on keys 2–9 (8 taps) and two more take a second slot (2 taps each): 8 + 4 = 12.
word consists of lowercase English lettersword are distinctword="plan"
4
Run checks the first 3 tests in your browser. Submit checks all 184 tests on the server, hidden ones included.