每日一题.551. 学生出勤记录 I
作者:互联网
解题思路
简单模拟
代码
class Solution {
public boolean checkRecord(String s) {
char[] chars = s.toCharArray();
int lateNum = 0,absentNum = 0,n = s.length();
for (int i=0;i<n;i++){
if (lateNum>=3 || absentNum>=2){
return false;
}
if (chars[i]=='A'){
absentNum++;
lateNum=0;
}
else if (chars[i]=='P'){
lateNum = 0;
}
else if (chars[i]=='L'){
lateNum++;
}
}
if (lateNum>=3 || absentNum>=2){
return false;
}
return true;
}
}
标签:lateNum,return,出勤,chars,551,absentNum,int,false,一题 来源: https://blog.csdn.net/weixin_45221477/article/details/120092512