My name is Siz. I am a computer science graduate student specializing in backend development with Golang and Python, seeking opportunities in innovative tech projects. My personal website is longsizhuo.com .Connect with me on LinkedIn: https://www.linkedin.com/in/longsizhuo/.
mine:The simple version of the simple out of the stack into the stack @ylq:right|Number count,The number is2Perform the multiple*Count
Code:
Out of the stack into the stack
1 2 3 4 5 6 7 8 9 10 11 12 13
classSolution: defcountAsterisks(self, s: str) -> int: stack = True flag = 0 for i in s: if stack: if i == '*': flag += 1 if i == '|'and stack: stack = False elif i == '|'andnot stack: stack = True return flag
ylq
1 2 3 4 5 6 7 8 9
classSolution: defcountAsterisks(self, s: str) -> int: count1, count2 = 0, 0 for i inrange(len(s)): if s[i] == '|': count1 += 1 if count1 % 2 == 0and s[i] == '*': count2 += 1 return count2