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

  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. 2019-7-3-如何通过命令行-msbuild-编译项目

    title author date CreateTime categories 如何通过命令行 msbuild 编译项目 lindexi 2019-07-03 19:12:19 +0800 2019- ...

  2. Python基础知识之4——三大控制结构

    控制结构就是控制程序执行顺序的结构. Python 有三大控制结构,分别是顺序结构.分支结构(选择结构)以及循环结构.任何一个项目或者算法都可以使用这三种结构来设计完成.这三种控制结构也是结构化程序 ...

  3. html--双飞翼布局

    <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title> ...

  4. Java虚拟机性能管理神器 - VisualVM(5) 监控远程主机上的JAVA应用程序【转】

    Java虚拟机性能管理神器 - VisualVM(5) 监控远程主机上的JAVA应用程序[转] 标签: javajvm监控工具性能优化 2015-03-11 18:37 1394人阅读 评论(0) 收 ...

  5. 高效开发 Dubbo?用 Spring Boot 可得劲!

    不仅简化了 Dubbo 基于 xml 配置的方式,也提高了日常开发效率,甚至提升了工作幸福感. 为了节省亲爱的读者您的时间,请根据以下2点提示来阅读本文,以提高您的阅读收获效率哦. 如果您只有简单的 ...

  6. Jdk8 Hashmap ConcurrentHashMap

    JDK1.8 Hashmap JDK1.8 ConcurrentHashMap 不采用segment而采用 synchronized (f)  f = table[i]; 减小锁的力度 设计了MOVE ...

  7. mysql limit 偏移量过大效率解决方式 转贴

    原文地址:https://www.jianshu.com/p/f8d81df7ab28 SELECT * FROM product , ) limit SELECT * FROM product a ...

  8. <随便写>WIN10家庭版调出策略组

    1.管理员运行cmd文件 2.运行窗口输入gpedit.msc 运行结果:

  9. Neo4j 第四篇:使用.NET驱动访问Neo4j

    本文使用的IDE是Visual Studio 2015 ,驱动程序是Neo4j官方的最新版本:Neo4j.Driver,创建的类库工程(Project)要求安装 .NET Framework 4.5. ...

  10. springboot整合aop实现网站访问日志记录

    目的: 统一日志输出格式,统计访问网站的ip. 思路: 1.针对不同的调用场景定义不同的注解,目前想的是接口层和服务层. 2.我设想的接口层和服务层的区别在于: (1)接口层可以打印客户端IP,而服务 ...