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. Linux -- 使用笔记

    Linux新增分辨率1920x1080 sudo gedit /etc/default/grub 找到:#GRUB_GFXMODE=640x480 在这行下面加一行GRUB_GFXMODE=1920x ...

  2. Python -- Gui编程 -- Qt库的使用 -- 配置资源文件

    1.源文件(qtRes.py) import sys from PyQt4 import QtCore, QtGui, uic class MyDialog(QtGui.QDialog): def _ ...

  3. Django之模型系统

    Django模型简介 Django 模型是与数据库相关的,与数据库相关的代码一般写在 models.py 中 Django 支持 sqlite3, MySQL, oracle,PostgreSQL等数 ...

  4. C#的进度条透明的情况(穿透问题)

    如图: 很明显,可以看到透过进度条的框框可以看到下面的软件界面, 之前出现这种情况是因为pictureBox和panel层级之间的关系造成的, 没想到这次的原因居然不是这样,而是因为少了backCol ...

  5. oracle存储过程删除树状结构的表数据

    今天在删除一个车辆品牌表的时候,遇到了一个问题,是在java的代码中做逻辑删除还是直接在Oracle中一次删除完成呢 思来想去觉得还是在sql里直接删除比较合适, 为什么呢? 第一,涉及数据库的读写操 ...

  6. rpm包的rpmbuild spec文件详解

    http://machael.blog.51cto.com/829462/213477 上一篇日志写到,为什么要制作rpm包,以及如何使用.src.rpm文件生成rpm包.最后部分还看到.src.rp ...

  7. [转]Enabling CRUD Operations in ASP.NET Web API 1

    本文转自:https://docs.microsoft.com/en-us/aspnet/web-api/overview/older-versions/creating-a-web-api-that ...

  8. [C语言] 数据结构-算法效率的度量方法-事前分析估算方法

    事前分析估算方法:在计算机程序编制前,依据统计方法对算法进行估算,抛开与计算机硬件软件有关的因素,一个程序的运行时间,依赖于算法的,好坏和问题的输入规模,所谓问题输入规模是指输入量的多少 推导过程,比 ...

  9. 零基础学C#算法(零基础学算法——C#版)

    今天本人正在看算法方面的书.作为高中数学忘得差不多的渣渣,实在无力.无奈找了本书,c语言写的,哎.我就把其中代码翻译成C#版好了.此坑能否填平,看我耐性和网络支持条件吧.有生之年能看完的话我会把整个项 ...

  10. lombok入门

    pom.xml加入依赖 <dependency> <groupId>org.projectlombok</groupId> <artifactId>lo ...