Skip to content

Commit 8f85e97

Browse files
committed
fix: show solutions
No.0009.Palindrome Number
1 parent 1a813d3 commit 8f85e97

File tree

2 files changed

+74
-0
lines changed

2 files changed

+74
-0
lines changed

solution/0000-0099/0009.Palindrome Number/README.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,43 @@ class Solution {
9191
}
9292
```
9393

94+
### **JavaScript**
95+
96+
```js
97+
/**
98+
* @param {number} x
99+
* @return {boolean}
100+
*/
101+
var isPalindrome = function (x) {
102+
let str = x + '';
103+
let left = 0,
104+
right = str.length - 1;
105+
while (left < right) {
106+
if (str[left] != str[right]) return false;
107+
left++;
108+
right--;
109+
}
110+
return true;
111+
};
112+
```
113+
114+
### **Go**
115+
116+
```go
117+
func isPalindrome(x int) bool {
118+
if x < 0 {
119+
return false
120+
}
121+
result := 0
122+
y := x
123+
for y != 0 {
124+
result = result * 10 + y%10
125+
y /= 10
126+
}
127+
return result == x
128+
}
129+
```
130+
94131
### **...**
95132

96133
```

solution/0000-0099/0009.Palindrome Number/README_EN.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,43 @@ class Solution {
8181
}
8282
```
8383

84+
### **JavaScript**
85+
86+
```js
87+
/**
88+
* @param {number} x
89+
* @return {boolean}
90+
*/
91+
var isPalindrome = function (x) {
92+
let str = x + '';
93+
let left = 0,
94+
right = str.length - 1;
95+
while (left < right) {
96+
if (str[left] != str[right]) return false;
97+
left++;
98+
right--;
99+
}
100+
return true;
101+
};
102+
```
103+
104+
### **Go**
105+
106+
```go
107+
func isPalindrome(x int) bool {
108+
if x < 0 {
109+
return false
110+
}
111+
result := 0
112+
y := x
113+
for y != 0 {
114+
result = result * 10 + y%10
115+
y /= 10
116+
}
117+
return result == x
118+
}
119+
```
120+
84121
### **...**
85122

86123
```

0 commit comments

Comments
 (0)