Wrong editorial code


#1

does not work with testcase A={0100},B=2


#2

Just add the following condition in the if statement (here v is the intervals array according to the editorial).

v[v.size()-1].second<n-1

Thus your if statement would be:

if(v[i].first>start || v[v.size()-1].second<n-1)
        return -1;

#3

even lightweight solution of c++ is also wrong for input
8 0 0 1 0 0 0 0 1
3