标签:student elf col not obj type com code 代码
这道题为简单题
1、这道题主要搞清楚两种情况就行了:
(1)、如果‘A’出现两次
(2)、如果出现‘LLL’
以上两种情况出现任意一种就返回False
我的代码:
1 class Solution(object): 2 def checkRecord(self, s): 3 """ 4 :type s: str 5 :rtype: bool 6 """ 7 a = 0 8 b = 0 9 for i in s: 10 if i == ‘A‘: 11 a += 1 12 b = 0 13 elif i == ‘L‘: 14 b += 1 15 else: 16 b = 0 17 if a == 2 or b == 3: return False 18 return True
简介代码:
def checkRecord(self, s): return not (s.count(‘A‘) > 1 or ‘LLL‘ in s)
标签:student elf col not obj type com code 代码
原文地址:http://www.cnblogs.com/liuxinzhi/p/7507070.html