# 551.Student Attendace Record I

**551.Student Attendance Record I**

难度:Easy

> 给定一个字符串来代表一个学生的出勤记录，这个记录仅包含以下三个字符：

'A' : Absent，缺勤 'L' : Late，迟到 'P' : Present，到场 如果一个学生的出勤记录中不超过一个'A'(缺勤)并且不超过两个连续的'L'(迟到),那么这个学生会被奖赏。

你需要根据这个学生的出勤记录判断他是否会被奖赏。

```
示例 1:

输入: "PPALLP"
输出: True
示例 2:

输入: "PPALLL"
输出: False
```

直接遍历，用两个计数器判断出勤和迟到，需要注意连续三次迟到才返回false。

```
class Solution {
public:
    bool checkRecord(string s) {
        int a=0;
        int l=0;
        for(auto c:s)
            if(c=='A')
            {
                ++a;
                l=0;
            }
            else if(c=='L' )   {  if( ++l >2) return false;}
            else            l=0;
      //  cout<<a << "  "<< l <<endl;
        return a<2 && l<3;
    }
};
```

> 执行用时 :0 ms, 在所有 C++ 提交中击败了100%的用户\
> 内存消耗 :8.2MB, 在所有 C++ 提交中击败了93.88%的用户
