Help me to find the corner case

https://www.codechef.com/viewsolution/60394512
Logic is , when i have the group of (maximum odd zeros and their length is)/2+1 > second maximum group of zeros . then only the player wins .
for the corner case if we have only one group and it is odd , then also player wins otherwise no.

There were two mistakes.

  1. You are only pushing lengths if it is followed by a blocked cell. What if last cell is not blocked ? To fix this just check length > 0 after the for loop and update the freq if so.
  2. freq.end - 1 is the iterator to the last element not the second last.

Check this corrected code.

1 Like

Thank you very much for helping me i get the AC
And for the first mistake , it is given in question last block would always be blocked.
Sir , if end() function reference to last element then , why we used end()-2

1 Like

to find the second last element of vector

Oh, my bad. Scratched the first point.

Look up std :: vector :: end.