Skip to content

Commit bca8830

Browse files
committed
Added Python solution to 'Count Asterisks'
1 parent 8ad399a commit bca8830

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
1-
class Solution:
2-
def countAsterisks(self, s: str) -> int:
3-
lst=[]
4-
for i in s:
5-
if '|' not in lst:
6-
lst.append(i)
7-
elif '|' in lst and i=='|':
8-
lst.pop()
9-
return lst.count('*')
1+
# Added on 2022-08-18 15:51:55.040392
2+
3+
var countAsterisks = function(s) {
4+
let green=true, count=0;
5+
for(let i=0; i<s.length; i++){
6+
if(green && s[i]=="*"){count++};
7+
if(s[i]=="|"){green=!green};
8+
}
9+
return count;
10+
};

0 commit comments

Comments
 (0)