Another Approach for lotto question done in video at 41:37

Prateek bhaiya was saying it can be done by bitmasking and bit operator. How to solve using bit operator. Can anyone help me???

PLease tell me the approach???