We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents 8bc3990 + 68407bf commit 54bde43Copy full SHA for 54bde43
number-of-1-bits/sm9171.java
@@ -0,0 +1,8 @@
1
+public static int hammingWeight(int n) {
2
+ int sum = 0;
3
+ while (n > 0) {
4
+ sum += n % 2;
5
+ n /= 2;
6
+ }
7
+ return sum;
8
+}
valid-palindrome/sm9171.java
@@ -0,0 +1,12 @@
+class Solution {
+ public boolean isPalindrome(String s) {
+ String str = s.toLowerCase().replaceAll("[^a-z0-9]","");
+ char[] charArray = str.toCharArray();
+ for (int i = 0; i < charArray.length / 2; i++) {
+ if (charArray[i] != charArray[charArray.length - i - 1]) {
+ return false;
9
10
+ return true;
11
12
0 commit comments