[leetcode-551-Student Attendance Record I]
2024-10-13 02:20:59
You are given a string representing an attendance record for a student.
The record only contains the following three characters:
'A' : Absent.
'L' : Late.
'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
bool checkRecord(string s) {
int a=, l=;
for(int i=;i<s.size();i++) {
if(s[i]=='A') a++;
if(s[i]=='L') l++;
else l=;
if(a>=||l>) return false;
}
return true;
}
最新文章
- gRPC C#学习
- 基于Nginx dyups模块的站点动态上下线并实现简单服务治理
- Hadoop: Hadoop Cluster配置文件
- ios视图frame和bounds的对比
- ecs CentOS 7 安装 mysql (mariadb)
- 几个最常用的git命令
- Back to Edit Distance(LCS + LIS)
- 回车键转tab键解决方案一
- Android_listView_BaseAdapter
- hibernate_validator_06
- IPTABLES封闭和开放端口
- iOS 8.0正式公布啦
- itextsharp生成pdf后的直接打印问题
- Tomcat初应用
- Bond UVA - 11354(LCA应用题)
- postgresql 定时任务备份及恢复
- centos7之zabbix3.2代理(zabbix-proxy)搭建
- 转:TCP为什么要3次握手和4次挥手时等待2MSL、 TCP如何保证消息顺序以及可靠性到达
- 【Unity】第10章 Mecanim动画系统
- MySQL慢日志简介及Anemometer工具介绍