Bit Manipulation Python Leetcode Solution