首页 > 其他 > 详细

Student Attendance Record I

时间:2017-09-11 21:51:47      阅读:181      评论:0      收藏:0      [点我收藏+]

    这道题为简单题

  题目:

    技术分享

 

  思路:

    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 Attendance Record I

原文:http://www.cnblogs.com/liuxinzhi/p/7507070.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!