Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 687217d

Browse files
authored
feat: add python solution to lc problem: No.0476 (#1882)
* Solution for 185. * style: format code and docs with prettier * Solution for 196. * Update README_EN.md * Update README.md * Solution for 197. * Solution for 262. * style: format code and docs with prettier * Solution for 319. * Solution for 332. * Solution for 468. * Solution for 476. --------- Co-authored-by: nrhitik <nrhitik@users.noreply.github.com>
1 parent c656e32 commit 687217d

File tree

3 files changed

+17
-0
lines changed

3 files changed

+17
-0
lines changed

‎solution/0400-0499/0476.Number Complement/README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,13 @@ class Solution:
7272
return ans
7373
```
7474

75+
```python
76+
class Solution:
77+
def findComplement(self, num: int) -> int:
78+
return num ^ (2 ** (len(bin(num)[2:])) - 1)
79+
80+
```
81+
7582
### **Java**
7683

7784
<!-- 这里可写当前语言的特殊实现逻辑 -->

‎solution/0400-0499/0476.Number Complement/README_EN.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ class Solution:
6060
return ans
6161
```
6262

63+
```python
64+
class Solution:
65+
def findComplement(self, num: int) -> int:
66+
return num ^ (2 ** (len(bin(num)[2:])) - 1)
67+
68+
```
69+
6370
### **Java**
6471

6572
```java
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
class Solution:
2+
def findComplement(self, num: int) -> int:
3+
return num ^ (2 ** (len(bin(num)[2:])) - 1)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /