1
1
leetcode/551.cpp
2023-05-11 22:33:32 +03:00

32 lines
528 B
C++

#include <string>
#include <iostream>
using namespace std;
class Solution
{
public:
bool checkRecord(string s)
{
int absent_count = 0;
for (int i = 0; i < s.length(); i++)
{
absent_count += (s[i] == 'A');
if (absent_count > 1)
return false;
}
for (int i = 0; i < (int)s.length() - 2; i++)
{
// cout<<i<<" "<<s[i]<<endl;
if (s[i] == 'A' && s[i] == s[i + 1] && s[i + 1] == s[i + 2])
return false;
}
return true;
}
};
int main() {
Solution s;
cout<<s.checkRecord("A")<<endl;
return 0;
}