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

  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. selenium基础(鼠标和键盘事件)

    selenium鼠标和键盘的操作事件 webdriver常见的几种操作方法 clear():清楚文本文字 send_keys(values):模拟按键输入,values是输入的内容 click():单 ...

  2. 我最恨ubuntu的自动升级内核功能

    总是提示我boot分区空间不足, 怎么办, 删除原有不用的内核呗,手动来做. 1.查看当前使用内核版本号.输入 uname -a 查看.uname -a 2.删除旧内核. 切换root: su 输入命 ...

  3. wangEditor富文本框——例

    官方文档:http://www.wangeditor.com/ 效果 html <!DOCTYPE html> <html> <head> <meta cha ...

  4. java_缓冲流(字符输出流)

    /** 字符缓冲流: * java.io.BufferedWriter extends writer * BufferedWriter:字符缓冲输出流: * * 构造方法: * BufferedWri ...

  5. iOS开发系列-JSON解析

    概述 JOSN是一种轻量级的数据格式,一般用于数据交互.服务器返回给客户端,一般都是JSON格式或者XML格式. JSON的格式: {"name" : "CoderHon ...

  6. iOS开发系列-NSOperation

    概述 NSOperation是基于GCD的封装更加面向对象,在使用上也是有任务跟队列的概念,分别对应两个类NSOperation .NSOperationQueue NSOperation和NSOpe ...

  7. Java中Arrys数组常用的方法

    Arrys常用方法 1.toString() Arrays.toString(arr)        //打印数组的内容,观察数组元素的值 2.sort() Arrays.sort(arr);     ...

  8. day1-初识Python以及环境搭建

    ---恢复内容开始--- 为什么学习Python? 软件质量:python的可读性很强,易于理解,非常接近于人类的自然语言. 提高开发者效率:相当于C,C++和JAVA等编译/静态型语言,Python ...

  9. 廖雪峰Java11多线程编程-3高级concurrent包-8CompletableFuture

    使用Future可以获得异步执行结果 Future<String> future = executor.submit(task); String result = future.get() ...

  10. 在自己的工程中使用开源界面库Duilib

    配置duilib库 一个简单的使用Duilib程序一般要在stdafx.h中进行配置(链接duilib的文件,包括头文件).通常的配置代码如下: 1 2 3 4 5 6 7 8 9 10 11 12 ...