Number Complement
class Solution(object):
def findComplement(self, num):
"""
:type num: int
:rtype: int
"""
res=0
i=0
while num>0:
if num&1 == 0:
res+=2**i
i=i+1
num=num>>1
#print "num: ", num
#print "res: ", res
return res
if __name__ == '__main__':
s=Solution()
print s.findComplement(5)