Next few post will all be about solving bitwise question.
return (x := 0, [x := x ^ v for v in nums])[-1][-1]
Approach 1 : using in-built fn to count 1 bits
Approach 2:
Think of a number in binary n = XXXXXX1000, n - 1 is XXXXXX0111. n & (n - 1) will be XXXXXX0000 which is just remove the last significant 1****
counting-bits/
self made one liner
Two Approach:
1) total_sum - n*(n+1)/2
2) xor of (1........n) ^(1...............n) == missing number
Top comments (0)