Re: [閒聊] 每日leetcode

作者: 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;
}
};
作者: JerryChungYC (JerryChung)   2024-08-06 09:11:00
大師 我也想睡
作者: sixB (6B)   2024-08-06 09:14:00
一起
作者: DJYOMIYAHINA (通通打死)   2024-08-06 09:35:00
放過我放過我放過我放過我放過我

Links booklink

Contact Us: admin [ a t ] ucptt.com