Leetcode551.Student Attendance Record I学生出勤记录1
给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符:
- 'A' : Absent,缺勤
- 'L' : Late,迟到
- '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的更多相关文章
- [LeetCode] Student Attendance Record II 学生出勤记录之二
Given a positive integer n, return the number of all possible attendance records with length n, whic ...
- 552 Student Attendance Record II 学生出勤记录 II
给定一个正整数 n,返回长度为 n 的所有可被视为可奖励的出勤记录的数量. 答案可能非常大,你只需返回结果mod 109 + 7的值.学生出勤记录是只包含以下三个字符的字符串: 1.'A' : ...
- [LeetCode] 552. Student Attendance Record II 学生出勤记录之二
Given a positive integer n, return the number of all possible attendance records with length n, whic ...
- [LeetCode] Student Attendance Record I 学生出勤记录之一
You are given a string representing an attendance record for a student. The record only contains the ...
- LeetCode 551. Student Attendance Record I (学生出勤纪录 I)
You are given a string representing an attendance record for a student. The record only contains the ...
- 551 Student Attendance Record I 学生出勤纪录 I
给定一个字符串来代表一个学生的出勤纪录,这个纪录仅包含以下三个字符: 'A' : Absent,缺勤 'L' : Late,迟到 'P' : Present,到场如果一个学生的出勤纪 ...
- [Swift]LeetCode552. 学生出勤记录 II | Student Attendance Record II
Given a positive integer n, return the number of all possible attendance records with length n, whic ...
- 551. Student Attendance Record I 从字符串判断学生考勤
[抄题]: You are given a string representing an attendance record for a student. The record only contai ...
- 【leetcode】552. Student Attendance Record II
题目如下: Given a positive integer n, return the number of all possible attendance records with length n ...
随机推荐
- VM 虚拟机使用桥接模式却连不上网的解决办法(转载)
只需将VM的虚拟网络编辑器中关于 VMnet0 的设置改一下就行了: 1.进入VMware的 编辑 -> 虚拟网络编辑器. 第一步 2.选择更改设置. 3.将VMnet0(或其它类型为桥接模式的 ...
- java_缓冲流(字节输出流)
缓冲流分为: 字节缓冲流:BufferedIntputSream(字节缓冲输出流),BufferdOutputStream(字节缓冲输入流) 字符缓冲流:BufferedReader(字符输入缓冲流) ...
- Tomcat的优化技巧
(1)参数 minProcessors:最小空闲连接线程数,用于提高系统处理性能,默认值为10. maxProcessors:最大连接线程数,即:并发处理的最大请求数,默认值为75. acceptCo ...
- java笔试之放苹果
题目描述:M个同样的苹果放在N个同样的盘子里,允许有的盘子空着不放,问共有多少种不同的分法?(用K表示)5,1,1和1,5,1 是同一种分法. 输入:每个用例包含二个整数M和N.0<=m< ...
- differential related impedance and termination
Impedance (1) Z0 Z0 is the impedance of one T-line while other lines are held at 0. Single end. (2) ...
- 系列文章:云原生Kubernetes日志落地方案
在Logging这块做了几年,最近1年来越来越多的同学来咨询如何为Kubernetes构建一个日志系统或者是来求助在这过程中遇到一系列问题如何解决,授人以鱼不如授人以渔,于是想把我们这些年积累的经验以 ...
- F. Cowmpany Cowmpensation dp+拉格朗日插值
题意:一个数,每个节点取值是1-d,父亲比儿子节点值要大,求方案数 题解:\(dp[u][x]=\prod_{v}\sum_{i=1}^xdp[v][i]\),v是u的子节点,先预处理出前3000项, ...
- 深入浅出 Java Concurrency (29): 线程池 part 2 Executor 以及Executors[转]
Java里面线程池的顶级接口是Executor,但是严格意义上讲Executor并不是一个线程池,而只是一个执行线程的工具.真正的线程池接口是ExecutorService. 下面这张图完整描述了线程 ...
- codeforces 1100E-Andrew and Taxi
传送门:QAQQAQ 题意:给你一个图,每条边有边权,现在你可以对边进行反转,使图中不存在环,你需要使得反转的边的边权集合中的最大值最小,并输出任意一组解. 思路:二分+拓扑排序 使得最大值最小,自然 ...
- VUX的使用方法(以弹出框为例)
一.安装 cnpm install vux --save cnpm install vux-loader --save-dev 二.配置 const vuxLoader = require('vux- ...