※ 引述《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;
}
};