We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 53a5323 commit 5279809Copy full SHA for 5279809
1291-sequential-digits.js
@@ -1,3 +1,36 @@
1
+/**
2
+ * @param {number} low
3
+ * @param {number} high
4
+ * @return {number[]}
5
+ */
6
+const sequentialDigits = function(low, high) {
7
+ const res = []
8
+
9
+ let q = []
10
+ for(let i = 1; i <= 9; i++) q.push(i)
11
12
+ while(q.length) {
13
+ const tmp = []
14
+ const size = q.length
15
+ for(let i = 0; i < size; i++) {
16
+ const cur = q[i]
17
+ if(cur >= low && cur <= high) {
18
+ res.push(cur)
19
+ }
20
+ if(cur > high) break
21
+ const last = cur % 10
22
+ if(last === 9) continue
23
+ tmp.push(cur * 10 + last + 1)
24
25
26
+ q = tmp
27
28
29
+ return res
30
+};
31
32
+// another
33
34
/**
35
* @param {number} low
36
* @param {number} high
0 commit comments