How can i solve it by bitmasking?

how can i solve it by bitmasking??