#include "laugh.h"
#include <bits/stdc++.h>
using namespace std;
int longest_laugh(string S)
{
int N = S.size();
S = '-' + S;
vector<int> dp(N + 1 , 0);
for (int i = 1;i <= N;i ++) {
if (S[i] == 'a' || S[i] == 'h') {
dp[i] = 1;
} else {
dp[i] = 0;
}
if (S[i] == 'a' && S[i - 1] == 'h') {
dp[i] += dp[i - 1];
} else if (S[i] == 'h' && S[i - 1] == 'a') {
dp[i] += dp[i - 1];
}
}
int eded = *max_element(dp.begin() , dp.end());
return (eded == 1 ? 0 : eded);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
numbers differ - expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
numbers differ - expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
numbers differ - expected: '1', found: '0' |
2 |
Halted |
0 ms |
0 KB |
- |