-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path906-Super-Palindromes.js
86 lines (84 loc) · 1.83 KB
/
906-Super-Palindromes.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/**
* @param {string} left
* @param {string} right
* @return {number}
*/
const superpalindromesInRange = (left, right) => {
const superpalindromes = [
1,
4,
9,
121,
484,
10201,
12321,
14641,
40804,
44944,
1002001,
1234321,
4008004,
100020001,
102030201,
104060401,
121242121,
123454321,
125686521,
400080004,
404090404,
10000200001,
10221412201,
12102420121,
12345654321,
40000800004,
1000002000001,
1002003002001,
1004006004001,
1020304030201,
1022325232201,
1024348434201,
1210024200121,
1212225222121,
1214428244121,
1232346432321,
1234567654321,
4000008000004,
4004009004004,
100000020000001,
100220141022001,
102012040210201,
102234363432201,
121000242000121,
121242363242121,
123212464212321,
123456787654321,
400000080000004,
10000000200000001,
10002000300020001,
10004000600040001,
10020210401202001,
10022212521222001,
10024214841242001,
10201020402010201,
10203040504030201,
10205060806050201,
10221432623412201,
10223454745432201,
12100002420000121,
12102202520220121,
12104402820440121,
12122232623222121,
12124434743442121,
12321024642012321,
12323244744232321,
12343456865434321,
12345678987654321,
40000000800000004,
40004000900040004
];
let count = 0;
for (const item of superpalindromes) {
if (+left <= item && item <= +right) count++;
}
return count;
};