All prompts are owned by LeetCode. To view the prompt, click the title link above.
First completed : August 06, 2024
Last updated : August 06, 2024
Related Topics : Hash Table, String, Greedy, Sorting, Counting
Acceptance Rate : 80.68 %
class Solution:
def minimumPushes(self, word: str) -> int:
cnt = sorted([f for f in Counter(word).values()])
output = 0
for i in range(len(cnt)) :
output += cnt[-i - 1] * (ceil((i + 1) / 8))
return output
class Solution:
def minimumPushes(self, word: str) -> int:
return sum([x * ceil(i / 8) for i, x in enumerate(sorted([f for f in Counter(word).values()], reverse=True), 1)])