Very simple c++ soln(pure bit manipulations):


#1

image