Re: [閒聊] 每日leetcode
※ 引述《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;
}
};
-----
Sent from JPTT on my iPad
--
※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 123.205.121.194 (臺灣)
※ 文章網址: https://www.ptt.cc/bbs/Marginalman/M.1722906271.A.718.html
推
08/06 09:11,
1年前
, 1F
08/06 09:11, 1F
→
08/06 09:14,
1年前
, 2F
08/06 09:14, 2F
→
08/06 09:35,
1年前
, 3F
08/06 09:35, 3F
推
08/06 12:30,
1年前
, 4F
08/06 12:30, 4F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 645 之 1548 篇):