2315. Count Asterisks
On This Page
class Solution:
def countAsterisks(self, s: str) -> int:
res, ok = 0, 1
for c in s:
if c == "*":
res += ok
elif c == "|":
ok ^= 1
return res