diff --git a/sequentialDigits b/sequentialDigits new file mode 100644 index 0000000..7493abc --- /dev/null +++ b/sequentialDigits @@ -0,0 +1,22 @@ +//https://leetcode.com/problems/sequential-digits/ + +func sequentialDigits(low int, high int) []int { + arr:=make([]int,0) + for i:=2;i<=9;i++{ + for j:=1;j<=10-i;j++{ + d:=j + n:=0 + for k:=1;k<=i;k++{ + n=n*10+d + d+=1 + } + if n>=low&&n<=high{ + arr=append(arr,n) + } + if n>high{ + break + } + } + } + return arr +}