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.
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 > 0after the
forloop and update the
freq.end - 1is the
iteratorto the last element not the second last.
Check this corrected code.
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
to find the second last element of vector
Oh, my bad. Scratched the first point.
Look up std :: vector :: end.