Some Things

In BFS visite all nodes inside the for(auto ch:graph[node]) loop

(-x) = 2's complement of x and 2's complement of x = (~x) + 1

Finding the right most set bit : (n & (-n))

Removing the right most set bit : (n- (n & (-n)))

Finding the left most set bit : (n & (n-1))

Finding the right most unset bit : (~n & (n+1))

Finding the left most unset bit : (~n & (n-1))

To check if a number is a power of 2: n & (n-1) == 0

a + b = (a XOR b) + 2*(a & b)

Last updated