Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 1d9917e

Browse files
committed
906 added
1 parent 70567e5 commit 1d9917e

File tree

5 files changed

+71
-2
lines changed

5 files changed

+71
-2
lines changed

.vscode/settings.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@
1010
"inention",
1111
"nbsp",
1212
"rorse",
13-
"stretchr"
13+
"stretchr",
14+
"superpalindrome",
15+
"superpalindromes"
1416
],
1517
"cSpell.language": "en,en-US"
1618
}
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# [906. Super Palindromes](https://leetcode.com/problems/super-palindromes/)
2+
3+
Let's say a positive integer is a *superpalindrome* if it is a palindrome, and it is also the square of a palindrome.
4+
5+
Now, given two positive integers `L` and `R` (represented as strings), return the number of *superpalindromes* in the inclusive range `[L, R]`.
6+
7+
Example 1:
8+
9+
```text
10+
Input: L = "4", R = "1000"
11+
Output: 4
12+
Explanation: 4, 9, 121, and 484 are *superpalindromes*.
13+
Note that 676 is not a *superpalindrome*: 26 * 26 = 676, but 26 is not a palindrome.
14+
```
15+
16+
Note:
17+
18+
1. `1 <= len(L) <= 18`
19+
1. `1 <= len(R) <= 18`
20+
1. `L` and `R` are strings representing integers in the range `[1, 10^18)`.
21+
1. `int(L) <= int(R)`
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
package problem0906
2+
3+
func superpalindromesInRange(L, R string) int {
4+
5+
return 0
6+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
package problem0906
2+
3+
import (
4+
"fmt"
5+
"testing"
6+
7+
"github.com/stretchr/testify/assert"
8+
)
9+
10+
// tcs is testcase slice
11+
var tcs = []struct {
12+
L, R string
13+
ans int
14+
}{
15+
16+
{
17+
"4",
18+
"1000",
19+
4,
20+
},
21+
22+
// 可以有多个 testcase
23+
}
24+
25+
func Test_superpalindromesInRange(t *testing.T) {
26+
ast := assert.New(t)
27+
28+
for _, tc := range tcs {
29+
fmt.Printf("~~%v~~\n", tc)
30+
ast.Equal(tc.ans, superpalindromesInRange(tc.L, tc.R), "输入:%v", tc)
31+
}
32+
}
33+
34+
func Benchmark_myFunc(b *testing.B) {
35+
for i := 0; i < b.N; i++ {
36+
for _, tc := range tcs {
37+
superpalindromesInRange(tc.L, tc.R)
38+
}
39+
}
40+
}

leetcode.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"Username": "aQuaYi",
33
"Ranking": 832,
4-
"Updated": "2018-11-06T16:37:45.356706534+08:00",
4+
"Updated": "2018-11-06T16:39:35.02979377+08:00",
55
"Record": {
66
"Easy": {
77
"Solved": 203,

0 commit comments

Comments
 (0)