2315. Count Asterisks

Updated: 2024-03-12
1 min read
[]

On This Page

LeetCode problem 2315

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