Skip to content

Commit f6fef11

Browse files
My solution for 476
1 parent b119987 commit f6fef11

File tree

1 file changed

+11
-2
lines changed

1 file changed

+11
-2
lines changed

problems/476/jeremymanning.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,20 @@
11
# [Problem 476: Number Complement](https://leetcode.com/problems/number-complement/description/?envType=daily-question)
22

33
## Initial thoughts (stream-of-consciousness)
4+
- This one is trivial-- there are built-in functions that can help
45

56
## Refining the problem, round 2 thoughts
7+
- We just need to return `int(bin(num)[2:].replace('0', 'x').replace('1', '0').replace('x', '1'), 2)`
68

79
## Attempted solution(s)
810
```python
9-
class Solution: # paste your code here!
10-
...
11+
class Solution:
12+
def findComplement(self, num: int) -> int:
13+
return int(bin(num)[2:].replace('0', 'x').replace('1', '0').replace('x', '1'), 2)
1114
```
15+
- Given test cases pass
16+
- Submitting...
17+
18+
![Screenshot 2024-08-21 at 8 08 15 PM](https://github.com/user-attachments/assets/0c32eac5-1704-46af-9ca3-24a00928b7ef)
19+
20+
Solved!

0 commit comments

Comments
 (0)