-
-
Save parcar/0ebba69eea6ec435ee047b19ab4c8884 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class Solution(object): | |
| def findComplement(self, num): | |
| """ | |
| :type num: int | |
| :rtype: int | |
| """ | |
| binary = [int(i) ^ 1 for i in bin(num)[2:]] | |
| return int("".join(map(str,binary)),2) | |
| ''' | |
| Runtime: 12 ms, faster than 89.42% of Python online submissions for Number Complement. | |
| Memory Usage: 11.9 MB, less than 14.29% of Python online submissions for Number Complement. | |
| ''' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment