1 class Solution:
 2     def isValid(self, S: str) -> bool:
 3         n = len(S)
 4         if n % 3 != 0:
 5             return False
 6         while n!=0:
 7             i = S.find('abc')
 8             if i == -1:
 9                 return False
10             else:
11                 S = S[0:i] + S[i+3:]
12                 n = len(S)
13         return True

 

posted on 2019-03-03 19:39  Sempron2800+  阅读(91)  评论(0编辑  收藏  举报