2315. Count Asterisks

Обновлено: 2024-03-12
1 мин
[]

Содержание

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