Solution1 Greedy
Traverse every even index, find the value's couple, then swap.
Find x's couple skill:
x is even, x ends with 0 in bianry, x ^ 1 turns 0 to 1, get x + 1
x is odd, x ends with 1 in binary, x ^ 1 turns 1 to 0, get x - 1
Last updated
Traverse every even index, find the value's couple, then swap.
Find x's couple skill:
x is even, x ends with 0 in bianry, x ^ 1 turns 0 to 1, get x + 1
x is odd, x ends with 1 in binary, x ^ 1 turns 1 to 0, get x - 1
Last updated