• + 0 comments

    I agree. That piece of code should be something like:

    if (k % 2 == 0 && ctnts[k/2] > 0) {
                cnt += 1;
     }
    

    The following case (and other similar cases) wouldn't work otherwise:

    4 8
    1 7 2 6