给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符:

  1. 'A' : Absent,缺勤
  2. 'L' : Late,迟到
  3. 'P' : Present,到场

如果一个学生的出勤纪录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏。

你需要根据这个学生的出勤纪录判断他是否会被奖赏。

示例 1:

输入: "PPALLP" 输出: True

示例 2:

输入: "PPALLL" 输出: False

class Solution {
public:
bool checkRecord(string s) {
int A = 0;
int len = s.size();
for(int i = 0; i < len; i++)
{
if(s[i] == 'A')
A++;
}
if(A >= 2)
return false;
for(int i = 2; i < len; i++)
{
if(s[i - 2] == 'L' && s[i - 1] == 'L' && s[i] == 'L')
return false;
}
return true;
}
};

Leetcode551.Student Attendance Record I学生出勤记录1的更多相关文章

  1. [LeetCode] Student Attendance Record II 学生出勤记录之二

    Given a positive integer n, return the number of all possible attendance records with length n, whic ...

  2. 552 Student Attendance Record II 学生出勤记录 II

    给定一个正整数 n,返回长度为 n 的所有可被视为可奖励的出勤记录的数量. 答案可能非常大,你只需返回结果mod 109 + 7的值.学生出勤记录是只包含以下三个字符的字符串:    1.'A' : ...

  3. [LeetCode] 552. Student Attendance Record II 学生出勤记录之二

    Given a positive integer n, return the number of all possible attendance records with length n, whic ...

  4. [LeetCode] Student Attendance Record I 学生出勤记录之一

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

  5. LeetCode 551. Student Attendance Record I (学生出勤纪录 I)

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

  6. 551 Student Attendance Record I 学生出勤纪录 I

    给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符:    'A' : Absent,缺勤    'L' : Late,迟到    'P' : Present,到场如果一个学生的出勤纪 ...

  7. [Swift]LeetCode552. 学生出勤记录 II | Student Attendance Record II

    Given a positive integer n, return the number of all possible attendance records with length n, whic ...

  8. 551. Student Attendance Record I 从字符串判断学生考勤

    [抄题]: You are given a string representing an attendance record for a student. The record only contai ...

  9. 【leetcode】552. Student Attendance Record II

    题目如下: Given a positive integer n, return the number of all possible attendance records with length n ...

随机推荐

  1. Caffe系列4——基于Caffe的MNIST数据集训练与测试(手把手教你使用Lenet识别手写字体)

    基于Caffe的MNIST数据集训练与测试 原创:转载请注明https://www.cnblogs.com/xiaoboge/p/10688926.html  摘要 在前面的博文中,我详细介绍了Caf ...

  2. Element-ui之修改样式

    修改样式的方法 官网上面介绍了几种方法: 当然还有其他的方法,比如: 直接在标签上面采用行内式: 在组件中的style里面添加样式: 引入.scss文件(注意:如果是公用样式最好在index.scss ...

  3. springboot下slf4j配置

    我们在引用的时候直接写 private static final Logger logger = LoggerFactory.getLogger(XXXServiceImpl.class); log. ...

  4. React中的Ajax

    React中的Ajax 组件的数据来源,通常是通过Ajax请求从服务器获取,可以使用componentDidMount方法设置Ajax请求,等到请求成功,再用this.setState方法重新渲染UI ...

  5. <<十二怒汉>>影评——程序正义,结果正义?

    <>影评--程序正义,结果正义? 这是一部黑白的,场景简单的(全电影的发生地只是一个房间),无趣且不讨喜的电影,但是这同时又是一部伟大的,深邃的,每个人看过之后都会陷入深深思考的电影.好的 ...

  6. VS2010-MFC(利用MFC向导生成单文档应用程序框架)

    一.VC++与MFC 讲VC++免不了要提MFC,MFC全称Microsoft Foundation Classes,也就是微软基础类库.它是VC++的核心,是C++与Windows API的结合,很 ...

  7. OpenCASCADE 平面与球面求交

    OpenCASCADE 平面与球面求交 eryar@163.com OpenCASCADE提供了类IntAna_QuadQuadGeo用来计算两个二次曲面quadric(球面.圆柱面.圆锥面及平面,平 ...

  8. MySQL Server Logs

    日志记录存储方式 #日志记录存储方式 mysql> show variables like 'log_output'; mysql> set global log_output='FILE ...

  9. Sql Server 2005主机和镜像切换SQL语句

    --1.主备互换 --主机执行: USE master; ALTER DATABASE <DatabaseName> SET PARTNER FAILOVER; --2.主服务器Down掉 ...

  10. 项目无法依赖Springboot打出的jar

    1.原因 因为springboot-maven-plugin打包的第一级目录为Boot-INF,无法引用 2.解决 不能使用springboot项目自带的打包插件进行打包 <build> ...