mirror of
https://git.wolves.top/wolves/leetcode.git
synced 2025-11-04 17:26:32 +08:00
init
This commit is contained in:
18
25/06/386.go
Normal file
18
25/06/386.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
func lexicalOrder(n int) []int {
|
||||
ans := make([]int, n)
|
||||
num := 1
|
||||
for i := 0; i < n; i++ {
|
||||
ans[i] = num
|
||||
if num*10 <= n {
|
||||
num *= 10
|
||||
} else {
|
||||
for num%10 == 9 || num+1 > n {
|
||||
num /= 10
|
||||
}
|
||||
num++
|
||||
}
|
||||
}
|
||||
return ans
|
||||
}
|
||||
Reference in New Issue
Block a user