Count Asterisks Problem
Count Asterisks Problem — ExecCode Easy DSA Practice
Solve the Count Asterisks problem on ExecCode. Free online easy DSA practice in String. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Description You are given a string s, where every two consecutive vertical bars '|' are grouped into a pair. Your task is to compute the required answer and return the number of '' in s , excluding the '' between each pair of '|'. In other words, the 1^st and 2^nd '|' make a pair, the 3^rd and 4^th '|' make a pair, and so forth. Note that each '|' will belong to exactly one pair.
Examples
Input {"s": "l|eet|c*o|de|"}; Output 2. Input {"s": "iamprogrammer"}; Output 0
Constraints
1 <= s.length <= 1000 s consists of lowercase English letters, vertical bars '|', and asterisks '*'. s contains an even number of vertical bars '|'.
Practice Count Asterisks free on ExecCode. Browse DSA problems, topic map, and placement guides.