class Solution:
def isValid(self, S: str) -> bool:
n = len(S)
if n % 3 != 0:
return False
while n!=0:
i = S.find('abc')
if i == -1:
return False
else:
S = S[0:i] + S[i+3:]
n = len(S)
return True
相关文章
- 03-13leetcode1003
2024-03-13 18:51:27
class Solution:
def isValid(self, S: str) -> bool:
n = len(S)
if n % 3 != 0:
return False
while n!=0:
i = S.find('abc')
if i == -1:
return False
else:
S = S[0:i] + S[i+3:]
n = len(S)
return True