We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 8ad399a commit bca8830Copy full SHA for bca8830
scripts/algorithms/C/Count Asterisks/Count Asterisks.py
@@ -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('*')
+# Added on 2022-08-18 15:51:55.040392
+
+var countAsterisks = function(s) {
+ let green=true, count=0;
+ for(let i=0; i<s.length; i++){
+ if(green && s[i]=="*"){count++};
+ if(s[i]=="|"){green=!green};
+ }
+ return count;
10
+};
0 commit comments