Re: [閒聊] 每日leetcode

作者: sixB (6B)   2024-10-15 09:39:16
2938.
蛤==
這題會medium是因為要開long long嗎
就從頭掃過去
看到0
看過幾個1就加
using ll = long long;
class Solution {
public:
long long minimumSteps(string s) {
ll res = 0;
int cur1 = 0;
for(char& c: s){
if(c == '1') cur1++;
else res += cur1;
}
return res;
}
};
作者: smart0eddie (smart0eddie)   2024-10-15 09:40:00
好久沒寫了LL
作者: DJYOSHITAKA (Evans)   2024-10-15 09:52:00
是你太強

Links booklink

Contact Us: admin [ a t ] ucptt.com