2315. Count Asterisks 發表於 2023-02-13 | 分類於 leetcode problemsolution12345678910111213141516171819class Solution {public: int countAsterisks(string s) { int ret = 0; bool flag = false; for(int i=0;i<s.size() ;i++){ if(s[i]=='|'){ i++; while(i<s.size() && s[i]!='|') i++; // i++; } else{ if(s[i]=='*') ret++; // i++; } } return ret; }}; analysis time complexity O(n) space complexity O(1)