位运算(持续更新)
判断奇偶性
if num & 1 == 1:
num % 2 == 1
# nums is odd number
if num & 1 == 0:
num % 2 == 0
# num is even number
异或
当 num 是偶数时,num + 1 = num ⊕ 1
当 num 是奇数时,num - 1 = num ⊕ 1
if num % 2 == 1:
num ^ 1 == num - 1
if num % 2 == 0:
num ^ 1 == num + 1