Transform to Chessboard

  • 0

    Click here to see the full article post

  • 0

    Thanks a lot!

    int ones = Integer.bitCount(k1 & Nones);

    Is "k1 & Nones" necessary here?

  • 0

    if (!(count.get(k1) == N/2 && count.get(k2) == (N+1)/2) &&
    !(count.get(k2) == N/2 && count.get(k1) == (N+1)/2))
    return -1;

    can be simplified to :
    if (Math.abs(count.get(k1)-count.get(k2))>1){
    return -1;

  • 0

    nice solution.

    i think if each row and each column is half ones or half zeros (or with an extra 1/0 when odd length) then it is impossible for there to be more or less than 2 distinct rows/columns. therefore those checks are redundant

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.