You are given a string representing an attendance record for a student. The record only contains the following three characters:

  1. 'A' : Absent.
  2. 'L' : Late.
  3. 'P' : Present.

A student could be rewarded if his attendance record doesn't contain more than one 'A' (absent) or more than two continuous 'L' (late).

You need to return whether the student could be rewarded according to his attendance record.

Example 1:

Input: "PPALLP"
Output: True

Example 2:

Input: "PPALLL"
Output: False
class Solution(object):
def checkRecord(self, s):
"""
:type s: str
:rtype: bool
"""
num_A=0
num_L=0 for i in s:
if i=='L':
if num_L>1:
return False
else:
num_L+=1
elif i=='A':
if num_A>0:
return False
else:
num_A+=1
num_L=0
else:
num_L=0
if num_A>1:
return False
return True

  

最新文章

  1. placeholder 颜色更改
  2. Visual Studio 2010中的stdafx.h和targetver.h两个头文件是有什么用?
  3. Android setTag方法的key问题
  4. hdu.5212.Code(莫比乌斯反演 && 埃氏筛)
  5. Oracle数据库3
  6. Android中MenuInflater实例
  7. tomcat学习笔记2
  8. iOS开发—字典转模型,KVC设计模式
  9. 4、Hbase
  10. 安装Java
  11. Oracle事物基础
  12. Count Color 线段树
  13. string转QBytearray
  14. 安装elasticsearch-7.0.0(centos)
  15. Hive:map字段存储和取用 ( str_to_map函数 )
  16. gitkraken clone报错 Configured SSH key is invalid
  17. 安装php rabbitmq扩展,继上一篇安装Rabbitmq
  18. CSS中一个冒号和两个冒号有什么区别
  19. python笔记9-字符串操作
  20. 在global.asax中启动定时任务

热门文章

  1. selinux介绍/状态查看/开启/关闭
  2. QPainter、QPainterPath、QBrush
  3. mac navicate 2013 - Lost connection to MySQL server at 'reading initial communication packet
  4. 中国队再创佳绩,IOI2018喜获四金
  5. 老毛桃制作装机版u盘
  6. Java的File.separator
  7. day10-高阶函数
  8. 【资料搜集】DirectX学习
  9. 《Python》IO模型
  10. delete请求