Can someone explain why my code is giving wrong answers for some test cases.
https://www.codechef.com/viewsolution/39193350
Contest Code:[LRNDSA02]
Problem Code:ZCO12001
Can someone explain why my code is giving wrong answers for some test cases.
https://www.codechef.com/viewsolution/39193350
Contest Code:[LRNDSA02]
Problem Code:ZCO12001
8
1 1 2 1 1 2 2 2
fo(i, 0, n) {
if (v[i] == 1) {
depth++;
}
else {
if (depth > max_depth) {
max_depth = depth;
depth_position = i;
}
depth = 0;
}
}
Think about this part. Why depth=0
when first 2
is found?