# 2315. Count Asterisks ###### tags: `Leetcode` `Easy` Link: https://leetcode.com/problems/count-asterisks/description/ ## Code ```java= class Solution { public int countAsterisks(String s) { int cnt = 0; boolean inPair = false; for(int i=0; i<s.length(); i++){ if(s.charAt(i)=='|') inPair = !inPair; if(!inPair && s.charAt(i)=='*') cnt++; } return cnt; } } ```
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up