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. php 比较2字符串相似度 百分比

    $n1 = similar_text($str1, $str1); $n2 = similar_text($str2, $str2); $nn = similar_text($str1, $str2) ...

  2. apache URL重写 标志表 以及 错误解决方法

    Apache mod_rewrite规则重写的标志一览 1) R[=code](force redirect) 强制外部重定向 强制在替代字符串加上http://thishost[:thisport] ...

  3. Android Kotlin开发之使用Butterknife注意要点

    使用kotlin-kapt插件 依赖由java的annotationProcessor改为kapt 在使用控件绑定使用时,网上搜使用方法,不知道被哪个家伙带坑里了. //错误用法 @BindView( ...

  4. java学习-GET方式抓取网页(UrlConnection和HttpClient)

    抓取网页其实就是模拟客户端(PC端,手机端...)发送请求,获得响应数据documentation,解析对应数据的过程.---自己理解,错误请告知 一般常用请求方式有GET,POST,HEAD三种 G ...

  5. mongodb中Gson和java##Bean对象转化类

    此类使用感觉比较繁琐, 每个字段加注解才可以使用, 不如mongoTemplate使用方便, 但如果使用mongo客户端的话, 还是比手动拼接快一点, 所以贴在这儿 package com.iwher ...

  6. Pipenv——最好用的python虚拟环境和包管理工具

    pipenv 是Kenneth Reitz大神的作品,能够有效管理Python多个环境,各种包.过去我们一般用virtualenv搭建虚拟环境,管理python版本,但是跨平台的使用不太一致,且有时候 ...

  7. javascript 方法总结(Array篇)

    1.toString:返回以数组种的每个值得字符串形式拼接而成得一个以逗号分割得字符串 toStringArr = [1, 2, 3, 4, 5, 6] console.log(toStringArr ...

  8. CentOS6.8启动Tomcat无法访问

    今天笔者在CentOS6.8的生产环境上配置Java环境,安装JDK,部署Tomcat,这本来是很简单的一件事,可是最后发现通过IP一直访问不了Tomcat的默认页面. 图1. 无法访问Tomcat默 ...

  9. [PHP] 深入理解PHP内核:变量及数据类型

    1.现实生活中我们会找一个小箱子来存放物品,一来显得不那么凌乱,二来方便以后找到.计算机也是这个道理,我们需要先在内存中找一块区域,规定用它来存放数据,并起一个好记的名字,方便以后查找.这块区域就是“ ...

  10. 2 duplicate symbols for architecture“文件冲突”

      我在配置第三方库拷贝示例文件中的库文件到新项目完成相关配置之后报下面的错误:   错误的原因是在解决问题之后发现的(第三方库的项目示例demo中的 要拷贝到自己项目中的库  并不需要全部添加到自己 ...