[leetcode]551. Student Attendance Record I
来源:互联网 发布:js获取手机唯一标识码 编辑:程序博客网 时间:2024/05/16 11:17
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
Solution:
package com.billkang;/** * @author binkang * @date May 23, 2017 */public class StudentAttendanceRecord1 {public boolean checkRecord(String s) {int a = 0;int l = 0;for (int i = 0; i < s.length(); ++i) {char c = s.charAt(i);if (c == 'P') {l = 0;continue;} else if (c == 'A') {l = 0;a++;if (a > 1) return false;} else {l++;if (l > 2) return false;}}return true;}}
阅读全文
1 0
- LeetCode 551. Student Attendance Record I
- [LeetCode]551. Student Attendance Record I
- LeetCode 551. Student Attendance Record I
- [leetcode]: 551. Student Attendance Record I
- [leetcode: Python]551. Student Attendance Record I
- [leetcode]551. Student Attendance Record I
- LeetCode-551. Student Attendance Record I (Java)
- leetcode#551. Student Attendance Record I
- leetcode 551. Student Attendance Record I
- leetcode 551. Student Attendance Record I
- LeetCode-551. Student Attendance Record I
- [LeetCode] 551. Student Attendance Record I
- leetcode 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 551. Student Attendance Record I
- 总结12--产生随机数
- 随机换色的两种思路
- AngularJs之Scope作用域
- 常用文本操作命令
- eclipse全局设置成UTF-8编码
- [leetcode]551. Student Attendance Record I
- 管理惯性
- MySQL系列—导入数据库文件:Unknown character set: 'utf8mb4' / mysql或MySQL server has gone away
- 操作系统内存管理
- 2016 第七届 蓝桥杯国赛 凑平方数
- 【Tensorflow】Anaconda中激活tensorflow后如何使用
- matlab之unwrap函数
- c++11模板别名using=
- 1764--矩阵转置(数据结构高分笔记)