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. EF 通过DataAnnotations配置属性和类型

    一.通过Attribute配置约束 1.主键约束 通过KeyAttribute来配置主键约束,代码如下: [Key] public int PrimaryKey{ get; set; } 2.外键约束 ...

  2. JS - 解决鼠标单击、双击事件冲突问题(原生js实现)

    由于鼠标双击时每一次触发双击事件都会引起两次单击事件和一次单击事件,原生的js不提供专门的双击事件. 因为业务原因,双击和单机都绑定了不同的业务,在双击的时候又触发了单机,影响了页面的正常显示 出现问 ...

  3. 【广州.NET社区推荐】.NETCore 平台上的日志集成组件 TomatoLog

    TomatoLog简介 TomatoLog 是一套在 .NETCore 平台上最简单易用的日志集成组件,具有高度灵活的使用方式,完全可定义配置的可扩展性,使用异步写入,业务完全解耦,客户端的一键安装. ...

  4. windows下快速启动或关闭系统服务方法

    在windows下有些后台服务会开机自动启动. 用命令行方式启动关闭应用服务 使用sc.exe命令功能列表 修改服务启动类型的命令行格式为(特别注意start=后面有一个空格) sc config 服 ...

  5. mongodb limit()和skip()

    MongoDB Limit() 方法 如果你需要在MongoDB中读取指定数量的数据记录,可以使用MongoDB的Limit方法,limit()方法接受一个数字参数,该参数指定从MongoDB中读取的 ...

  6. elasticsearch插件安装之--中文分词器 ik 安装

    /** * 系统环境: vm12 下的centos 7.2 * 当前安装版本: elasticsearch-2.4.0.tar.gz */ ElasticSearch中内置了许多分词器, standa ...

  7. Nodejs学习笔记(七)—Node.js + Express 构建网站简单示例

    前言 上一篇学习了一些构建网站会用到的一些知识点:https://www.cnblogs.com/flyingeagle/p/9192936.html 这一篇主要结合前面讲到的知识,去构建一个较为完整 ...

  8. Windows 查看程序占用的端口

    一. 查看所有进程占用的端口  在开始-运行-cmd,输入:netstat –ano可以查看所有进程 二.查看占用指定端口的程序  当你在用tomcat发布程序时,经常会遇到端口被占用的情况,我们想知 ...

  9. ADB故障时的一些命令

    开发中经常用到adb重启等操作,简单记录一下. 1.重启 adb kill-server adb start-server 2.显示版本号 adb version 3.显示已连接的设备 adb dev ...

  10. Linux 64位 CentOS下安装 Docker 容器,启动、停止

    一.Docker简介 Docker 提供了一个可以运行你的应用程序的封套(envelope),或者说容器,是轻量级的“容器引擎+映像仓库”,在LXC(linux轻量级容器)的基础上构建,可以运行任何应 ...