Array
3644. Maximum K to Sort a Permutation
Every element sitting in the wrong place has to be swapped at least once, and every legal swap has its two values ANDing to exactly k, which means both of them carry all the bits of k. Chain those two facts and k can only be a submask of every misplaced value, so the answer never exceeds the AND of
Loading…