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.
2 parents d7ef7df + 43c8be2 commit fb930e4Copy full SHA for fb930e4
number-of-1-bits/sooooo-an.ts
@@ -0,0 +1,3 @@
1
+function hammingWeight(n: number): number {
2
+ return n.toString(2).replace(/0/g, "").length;
3
+}
valid-palindrome/sooooo-an.ts
@@ -0,0 +1,20 @@
+function isPalindrome(s: string): boolean {
+ const cleanString = s
+ .toLowerCase()
4
+ .replace(/\s+/g, "")
5
+ .replace(/[^a-z0-9]/g, "");
6
+
7
+ let left = 0;
8
+ let right = cleanString.length - 1;
9
10
+ while (left < right) {
11
+ if (cleanString[left] !== cleanString[right]) {
12
+ return false;
13
+ }
14
15
+ left++;
16
+ right--;
17
18
19
+ return true;
20
0 commit comments