Skip to content

Practice Count Asterisks

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Easy#2315
LeetCode Problem

Count Asterisks

Problem Statement

You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. In other words, the 1st and 2nd '|' make a pair, the 3rd and 4th '|' make a pair, and so forth. Return the number of '*' in s, excluding the '*' between each pair of '|'. Note that each '|' will belong to exactly one pair.

Source: Count Asterisks on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "l|*e*et|c**o|*de|"
Output
2

# Example 2

Input
s = "iamprogrammer"
Output
0

# Example 3

Input
s = "yo|uar|e**|b|e***au|tifu|l"
Output
5

Constraints

1 <= s.length <= 1000
s consists of lowercase English letters, vertical bars '|', and asterisks '*'.
s contains an even number of vertical bars '|'.

Related LeetCode Problems

Practice more problems similar to Count Asterisks.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.