2268. Minimum Number of Keypresses
On This Page
class Solution:
def minimumKeypresses(self, s: str) -> int:
cnt = Counter(s)
res = 0
i, j = 0, 1
for v in sorted(cnt.values(), reverse=True):
i += 1
res += j * v
if i % 9 == 0:
j += 1
return res