题目:
思路:
遍历就完事了.连续三天不来return false; 超过两次缺勤 fasle;
代码是:
//code
class Solution {
public:
bool checkRecord(string s) {
int n = s.length();
int abtimes=0,latimes=0;
for(int i=0;i<n;i++){
switch(s[i]){
case('A'):
latimes=0;
abtimes++;
break;
case('L'):
++latimes;
if(latimes>=3){
return false;
}
break;
default:
latimes=0;
break;
}
}
if(abtimes>=2) return false;
return true;
}
};