Sequential Digits | LeetCode 1291 | C++, Java, Python

preview_player
Показать описание

**** Best Books For Data Structures & Algorithms for Interviews:**********
*****************************************************************************

September LeetCoding Challenge | Problem 19 | Sequential Digits | 19 September,
Facebook Coding Interview question,
google coding interview question,
leetcode,
Sequential Digits,
Sequential Digits c++,
Sequential Digits Java,
Sequential Digits python,
Sequential Digits solution,
1291. Sequential Digits,

#CodingInterview #LeetCode #Google #Amazon
Рекомендации по теме
Комментарии
Автор

Thanks for that. I implemented this 2 different ways, neither of which was this. For the 2nd approach, I made an array of all the possible sequential numbers (there's only 45 of them) and returned the subarray which matched the low-high range.

crankyinmv
Автор

Sir, would you mind doing explanation videos for weekly contest questions. Always stuck with hard problems and solution in "discuss" section are not very helpful for beginners like me :(

rajeshg
Автор

Please Continue Doing Videos on Daily Leetcoding Challenge.

surajkiranreddymothe
Автор

thank you may god help you
keep going this nice series
you really help and motivate us to continue with you

moayyadarz
Автор

My solution(doesn't require any conversion from string to number or number to string)
vector<int> sequentialDigits(int low, int high) {
long val=0, prod=1, i, num=0, prev;
for(i=0; i<to_string(low).length(); i++){
num = (i+1)+ num*10;
val += prod;
prod *= 10;
}
prev=num;
vector<int> res;
while(num <= high){
if(num >= low)
res.push_back(num);
num += val;
if(num%10 == 0){
val += prod;++i;
num = prev*10+i;
prod *= 10;
prev = num;
}
}
return res;
}

rishisharma
Автор

Sir is there any way that I can contact you . I am having some doubt so can you please co-operate .

ashutoshtiwari
Автор

Why use 10-i???
string is of 9 elements so <=9-i; It is more intuitive

clashtm
Автор

Sir, can you share your LinkedIn I'd, I would like to connect with you.
Thank you for everyday awesome content.

Brijeshkumar-lkmt
join shbcf.ru