楼主:
sixB (6B)
2024-08-06 09:04:28※ 引述《JerryChungYC (JerryChung)》之铭言:
: https://leetcode.com/problems/minimum-number-of-pushes-to-type-word-ii
: 3016. Minimum Number of Pushes to Type Word II
睡不着看你版文
medium怎么比周赛easy还简单==
看都看了就顺手写掉
不然记在心上更睡不着
好像多开了几个东西计
大差不差
我要继续尝试睡着了
class Solution {
public:
int minimumPushes(string word) {
vector<int> alp(26, 0);
for(char c: word){
alp[c - 'a']++;
}
sort(alp.begin(), alp.end(), [](int a, int b){return a > b;});
int res = 0, add = 1, cnt = 0;
for(int i : alp){
res += i * add;
cnt++;
if(cnt == 8){
cnt = 0;
add++;
}
cout << res << '\n';
}
return res;
}
};