#include "laugh.h"
#include <bits/stdc++.h>
using namespace std;
int longest_laugh(std::string s)
{
int cnt = 0;
char last = 'z';
int mx = 0;
for (int i = 0; i < (int) s.size(); ++i) {
if (last == 'z' && (s[i] == 'a' || s[i] == 'h')) {
last = s[i];
++cnt;
} else if ((s[i] == 'a' || s[i] == 'h') && s[i] != last) {
++cnt;
if (last == 'z') last = s[i];
else if (last == 'a') last = 'h';
else last = 'a';
} else {
last = 'z';
mx = max(mx, cnt);
cnt = 0;
}
}
mx = max(mx, cnt);
return mx;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
numbers differ - expected: '2', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
numbers differ - expected: '2', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Incorrect |
0 ms |
204 KB |
numbers differ - expected: '2', found: '1' |
3 |
Halted |
0 ms |
0 KB |
- |