Skip to content

Commit

Permalink
add sol
Browse files Browse the repository at this point in the history
  • Loading branch information
ductnn committed Feb 3, 2024
1 parent 835a81b commit 46de941
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions leetcode/1291.SequentialDigits/sequentialDigits.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
// https://leetcode.com/problems/sequential-digits

package main

import (
"fmt"
"sort"
)

func sequentialDigits(low int, high int) []int {
ans := []int{}
for i := 1; i < 9; i++ {
x := i
for j := i + 1; j < 10; j++ {
x = x*10 + j
if low <= x && x <= high {
ans = append(ans, x)
}
}
}
sort.Ints(ans)
return ans
}

func main() {
low := 100
high := 300

fmt.Println(sequentialDigits(low, high))
}

0 comments on commit 46de941

Please sign in to comment.