2022年12月2日 星期五

[551] Student Attendance Record I

可愛的題目~(心)
bool checkRecord(char * s){
int Absent=0;
int Late=0;
for (int i=0;i<strlen(s);i++)
{
if (s[i]!='L')
Late=0;
else
{
Late++;
if (Late>=3)
return false;
}
if (s[i]=='A')
{
Absent++;
if (Absent>=2)
return false;
}
}
if (Absent>=2 || Late>=3)
return false;
return true;
}

沒有留言:

張貼留言