There was an error while loading. Please reload this page.
1 parent 1c55de3 commit d6c48aeCopy full SHA for d6c48ae
.vscode/settings.json
@@ -0,0 +1,3 @@
1
+{
2
+ "cSpell.words": ["Palindrom"]
3
+}
9-palindrom.js
@@ -0,0 +1,14 @@
+//-121 is palindrom or not?
+
+function isPalindrom(num) {
4
+ let temp = num;
5
+ let rev = 0;
6
+ while (temp > 0) {
7
+ let lastDigit = temp % 10;
8
+ rev = rev * 10 + lastDigit;
9
+ temp = Math.floor(temp / 10);
10
+ }
11
+ return rev === num;
12
13
14
+isPalindrom(-121)
0 commit comments