Hey I found problems on HackerRank is more interesting than ones on LeetCode..
Strategy: observeanalyze bit by bit - DISCRETE THINKING. The idea is like this: if we can XOR any bit in original number X to make that bit into 1 from 0, then any bits following that bit don't matter; and we go check bit by bit. This is also the sln in editorial.

t = int(raw_input()) for i in xrange(t): n = int(raw_input()) j = 0 cnt = 0 while n > 0: if (n&1) == 0: cnt += pow(2, j) j += 1 n >>= 1 print cnt