How to solve this problem?

The tutorial has used bit operators /bitmask to solve this ,but I am not able to understand it ,Can
Someone help …