Skip to content

Commit 5b75f46

Browse files
authored
Create 3014. Minimum Number of Pushes to Type Word I.py
1 parent 0818a53 commit 5b75f46

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def minimumPushes(self, word: str) -> int:
3+
counter = Counter(word)
4+
freq_num = [[freq, num] for num, freq in counter.items()]
5+
freq_num.sort()
6+
7+
ans = 0
8+
counter = 0
9+
10+
while freq_num:
11+
freq, num = freq_num.pop()
12+
cost = counter // 8 + 1
13+
counter+=1
14+
ans+=cost * freq
15+
return ans

0 commit comments

Comments
 (0)