class Solution {
public:
int countAsterisks(string s) {
// 当前遇到的竖线个数
int verNum = 0;
int ans = 0;
for(int i = 0; i < s.size(); i++){
if(0 == (verNum & 0x01)){
// 如果当前遇到的竖线个数为偶数个,则可以记录*的个数
if(s[i] == '*'){
ans++;
continue;
}
}
// 记录竖线的个数
if(s[i] == '|'){
verNum++;
}
}
return ans;
}
};
01-29
535
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交