We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 6064152 commit 3998c84Copy full SHA for 3998c84
递归与回溯/顺次数-1291.js
@@ -0,0 +1,30 @@
1
+/**
2
+ * @param {number} low
3
+ * @param {number} high
4
+ * @return {number[]}
5
+ */
6
+let sequentialDigits = function (low, high) {
7
+ let lowLen = low.toString().length
8
+ let highLen = high.toString().length
9
+ let lens = []
10
+ for (let i = lowLen; i <= highLen; i++) {
11
+ lens.push(i)
12
+ }
13
+
14
+ let res = []
15
+ for (let i = 0; i < lens.length; i++) {
16
+ let len = lens[i]
17
+ for (let start = 1; start <= 10 - len; start++) {
18
+ let num = start
19
20
+ for (let n = start + 1; n < start + len; n++) {
21
+ num = 10 * num + n
22
23
+ if (num <= high && num >= low) {
24
+ res.push(num)
25
26
27
28
29
+ return res
30
+}
0 commit comments