Skip to content

Commit 29212ad

Browse files
AE-Hertzidoocs
authored andcommitted
style: format code and docs with prettier
1 parent b7c22ac commit 29212ad

File tree

2 files changed

+17
-6
lines changed

2 files changed

+17
-6
lines changed

solution/0500-0599/0564.Find the Closest Palindrome/README_EN.md

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@ func abs(x int) int {
188188
```
189189

190190
#### JavaScript
191+
191192
```js
192193
/**
193194
* @param {string} n
@@ -216,13 +217,19 @@ function getCandidates(n) {
216217
const res = new Set();
217218

218219
res.add(BigInt(Math.pow(10, length - 1) - 1));
219-
res.add(BigInt(Math.pow(10, length) + 1));
220+
res.add(BigInt(Math.pow(10, length) + 1));
220221

221222
const left = BigInt(n.substring(0, Math.ceil(length / 2)));
222223

223224
for (let i = left - 1n; i <= left + 1n; i++) {
224225
const prefix = i.toString();
225-
const t = prefix + prefix.split('').reverse().slice(length % 2).join('');
226+
const t =
227+
prefix +
228+
prefix
229+
.split('')
230+
.reverse()
231+
.slice(length % 2)
232+
.join('');
226233
res.add(BigInt(t));
227234
}
228235

@@ -233,7 +240,6 @@ function getCandidates(n) {
233240
function absDiff(a, b) {
234241
return a > b ? a - b : b - a;
235242
}
236-
237243
```
238244

239245
<!-- tabs:end -->

solution/0500-0599/0564.Find the Closest Palindrome/Solution.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,13 +25,19 @@ function getCandidates(n) {
2525
const res = new Set();
2626

2727
res.add(BigInt(Math.pow(10, length - 1) - 1));
28-
res.add(BigInt(Math.pow(10, length) + 1));
28+
res.add(BigInt(Math.pow(10, length) + 1));
2929

3030
const left = BigInt(n.substring(0, Math.ceil(length / 2)));
3131

3232
for (let i = left - 1n; i <= left + 1n; i++) {
3333
const prefix = i.toString();
34-
const t = prefix + prefix.split('').reverse().slice(length % 2).join('');
34+
const t =
35+
prefix +
36+
prefix
37+
.split('')
38+
.reverse()
39+
.slice(length % 2)
40+
.join('');
3541
res.add(BigInt(t));
3642
}
3743

@@ -42,4 +48,3 @@ function getCandidates(n) {
4248
function absDiff(a, b) {
4349
return a > b ? a - b : b - a;
4450
}
45-

0 commit comments

Comments
 (0)