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 5f548c6

Browse files
add solution in Python for 0231_power_of_two.py
1 parent 6b45e73 commit 5f548c6

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

‎python_solutions/0231_power_of_two.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
def isPowerOfTwo(self, n: int) -> bool:
2+
# Here bitwise operation is used (specifically AND)
3+
return n > 0 and (n & n - 1) == 0

0 commit comments

Comments
(0)

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