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