Tap here to switch tabs
Problem
Submissions

Problem: Count Asterisks

med
30 min
Try to solve the Count Asterisks problem.

Statement

Given a string s, count the number of asterisks '*' that do not appear between any pair of vertical bars '|'.

The vertical bars '|' are paired consecutively from left to right. That is, the characters between the 1extst1^{ ext{st}} and 2extnd2^{ ext{nd}} bar, between the 3extrd3^{ ext{rd}} and 4extth4^{ ext{th}} bar, and so on, are excluded from the count.

Return the total number of valid asterisks.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • s consists of lowercase English letters, vertical bars '|', and asterisks '*'.

  • s contains an even number of vertical bars '|'.

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Count Asterisks

med
30 min
Try to solve the Count Asterisks problem.

Statement

Given a string s, count the number of asterisks '*' that do not appear between any pair of vertical bars '|'.

The vertical bars '|' are paired consecutively from left to right. That is, the characters between the 1extst1^{ ext{st}} and 2extnd2^{ ext{nd}} bar, between the 3extrd3^{ ext{rd}} and 4extth4^{ ext{th}} bar, and so on, are excluded from the count.

Return the total number of valid asterisks.

Constraints:

  • 1≤1 \leq s.length ≤1000\leq 1000

  • s consists of lowercase English letters, vertical bars '|', and asterisks '*'.

  • s contains an even number of vertical bars '|'.