1、题目描述

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 输入一个string ,如果其中连续出现出现两次 ‘A’,或者连续出现三次 ‘L’返回false。 2、代码
 bool checkRecord(string s) {

         int numA = ;
int numL = ;
for(int i = ; i < s.size(); i++)
{
if(s[i] == 'A' && ++numA > )
return false; if(s[i] == 'L')
{
numL++;
if(numL > )
return false;
} else
numL = ;
}
return true;
}

leetCode题解 Student Attendance Record I的更多相关文章

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

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

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

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

  3. LeetCode 551. Student Attendance Record I (C++)

    题目: You are given a string representing an attendance record for a student. The record only contains ...

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

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

  5. 【leetcode】552. Student Attendance Record II

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

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

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

  7. 552. 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. 551. Student Attendance Record I【easy】

    551. Student Attendance Record I[easy] You are given a string representing an attendance record for ...

随机推荐

  1. android 使用lint + studio ,排查客户端无用string,drawable,layout资源

    在项目中点击右键(或者菜单中的Analyze),在出现的右键菜单中有“Analyze” --> “run inspaction by Name ...”.在弹出的搜索窗口中输入想执行的检查类型, ...

  2. 工具类APP

    应用名称 工具S 英文名称 未填写 应用描述 工具类APP 英文描述 未填写 应用官网 this 应用图标  

  3. jquery插件开发的demo

    (function ($) { $.fn.extend({ "highLight": function (options) { //检测用户传进来的参数是否合法 if (!isVa ...

  4. jQuery为图片添加链接(创建新的元素来包裹选中的元素)

    主要用到 wrap()函数 http://www.w3school.com.cn/jquery/manipulation_wrap.asp 这个函数是创建新的的元素去包裹所执行这个方法的元素 如下例子 ...

  5. Spring AOP 的实现

    软件152 余建强 1 使用 API 实现 AOP 新建一个用户接口:UserService package com.cqvie.aop.api; public interface UserServi ...

  6. 添加List集合覆盖问题

    今天在做一个项目的时候,发现了这样一个问题,为了让大家看得更直接明了,我直接放代码: public void InsertObjectToList(){ List<NewsProtetype&g ...

  7. SpringMVC 面试题

    SpringMVC 面试题 什么是Spring MVC ?简单介绍下你对springMVC的理解? Spring MVC是一个基于MVC架构的用来简化web应用程序开发的应用开发框架,它是Spring ...

  8. Java JDK 配置环境变量

    使用了java也有了两年了,安装了很多次jdk都记不住安装步骤 = =,刚刚又配置了一次,码一下步骤: 1.右击"此电脑" ---> "属性" ----& ...

  9. commons-fileupload-1.4使用及问题

    文件上传 使用commons-fileupload-1.4控件及依赖的commons-io-2.6控件 jsp页面中内容 <form action="../servlet/FileUp ...

  10. hdu 3085

    Nightmare Ⅱ Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...