Skip to content

Latest commit

 

History

History
45 lines (32 loc) · 1.29 KB

_3016. Minimum Number of Pushes to Type Word II.md

File metadata and controls

45 lines (32 loc) · 1.29 KB

All prompts are owned by LeetCode. To view the prompt, click the title link above.

Back to top


First completed : August 06, 2024

Last updated : August 06, 2024


Related Topics : Hash Table, String, Greedy, Sorting, Counting

Acceptance Rate : 80.68 %


Solutions

Python

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)])