Skip to content

Latest commit

 

History

History
20 lines (15 loc) · 744 Bytes

jeremymanning.md

File metadata and controls

20 lines (15 loc) · 744 Bytes

Initial thoughts (stream-of-consciousness)

  • This one is trivial-- there are built-in functions that can help

Refining the problem, round 2 thoughts

  • We just need to return int(bin(num)[2:].replace('0', 'x').replace('1', '0').replace('x', '1'), 2)

Attempted solution(s)

class Solution:
    def findComplement(self, num: int) -> int:
        return int(bin(num)[2:].replace('0', 'x').replace('1', '0').replace('x', '1'), 2)
  • Given test cases pass
  • Submitting...

Screenshot 2024-08-21 at 8 08 15 PM

Solved!