From 07564b83d8ecd2769bee59601f9466cd08d36998 Mon Sep 17 00:00:00 2001 From: Akshay Agarwal Date: Fri, 2 Oct 2020 16:21:46 +0530 Subject: [PATCH] Create sequentialDigits https://leetcode.com/submissions/detail/397817386/ --- sequentialDigits | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 sequentialDigits 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 +}