leetcode551: Student Attendance Record I
来源:互联网 发布:音频信号发生器软件 编辑:程序博客网 时间:2024/06/04 19:05
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
public boolean checkRecord(String s) {char[] c = s.toCharArray();int countA = 0;boolean countL1 = false;boolean countL2 = false;for (int i = 0; i < c.length; i++) {if (c[i] == 'A') {countA++;countL1 = false;countL2 = false;} else if (c[i] == 'P') {countL1 = false;countL2 = false;} else if (countL1 != true)countL1 = true;else if (countL1 = true && countL2 != true)countL2 = true;elsereturn false;if (countA > 1)return false;}return true;}
0 0
- leetcode551: Student Attendance Record I
- leetcode551. Student Attendance Record I
- Leetcode551. Student Attendance Record I一趟遍历
- Student Attendance Record I
- Student Attendance Record I
- 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
- 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
- 551. Student Attendance Record I
- cv::Mat 对像素进行操作取地址
- 数据结构与算法---栈
- css的6大布局方式
- 这个前端面试在搞事!
- object detection资料汇总
- leetcode551: Student Attendance Record I
- 欢迎使用CSDN-markdown编辑器
- Fiddler抓包工具的手机端的使用
- 机器学习面试问题汇总
- 将文件根据不同日期进行分类(文件归档)
- vivado 中的一个三态问题(封装IIC的axi总线IP)
- 第一篇
- POJ 1721-CARDS(置换群-单个循环置换幂运算 倒推)
- Pattern与Matcher类