mv a file into correct difficulty

This commit is contained in:
bumpsoo 2024-08-15 14:45:51 +09:00
parent e6c5de02e1
commit 20e6afc45d

View file

@ -0,0 +1,19 @@
# https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-ii
from collections import Counter
from functools import reduce
class Solution:
def minimumPushes(self, word: str) -> int:
cnt = Counter(word)
lst = sorted(cnt.values(), reverse=True)
push = 1
ret = 0
for i in range(0, len(lst), 8):
ret += reduce(
lambda x, y: x + y * push,
lst[i:i + 8 if i + 8 < len(lst) else len(lst)],
0
)
push += 1
return ret