2025-08-18 17:07:07 +0000 UTC

Count Asterisks

Code

class Solution:
    def countAsterisks(self, s: str) -> int:
        start = False
        res = 0
        for char in s:
            if char == "|":
                start = not start
            elif char == "*" and not start:
                res += 1
        return res