We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 840701f commit 3673158Copy full SHA for 3673158
number-of-1-bits/ppxyn1.py
@@ -0,0 +1,10 @@
1
+# idea: -
2
+
3
+from collections import Counter
4
+class Solution:
5
+ def hammingWeight(self, n: int) -> int:
6
+ bits = bin(n).split('0b')[-1]
7
+ return Counter(bits)['1']
8
9
10
valid-palindrome/ppxyn1.py
@@ -0,0 +1,11 @@
+# idea : regex
+import re
+ def isPalindrome(self, s: str) -> bool:
+ alphabet = re.sub(r'[^A-Za-z0-9]', '', s).lower()
+ return alphabet == alphabet[::-1]
11
0 commit comments