Sequential Digits | Leetcode 1291 |Live coding session 🔥🔥🔥🔥 | TC O(1)

preview_player
Показать описание
👉Here is the solution to "Sequential Digits" leetcode question. Hope you have a great time going through it.

1) 0:00 Explaining the problem out loud
2) 1:10 Algorithm walkthrough
3) 2:15 Coding it up

👉Java:
Solution

🔥🔥🔥🔥👇👇👇 For discussion/feedback/humour/doubts/new openings

🔴 Checkout the series: 🔥🔥🔥

🔥🔥🔥 Leetcode Monthly Contest Playlist

PS : Please increase the speed to 1.25X
Рекомендации по теме
Комментарии
Автор

Damn, that's smart, didn't think of that, kept on getting time limit exceeded, well done dude

sylascoker
Автор

vector<int> sequentialDigits(int low, int high) {
vector<int>v;
int x1=1;
int x=low;
int count=0;
while(x){
count++;
x=x/10;
}
int p=count;
while(true){
int number=0;
for(int i=x1;i<=count;i++){
number=number*10+i;
}
x1++;
count=count+1;
if(number>=low && number<=high){
v.push_back(number);
}
if(number%10==9){
x1=1;
p++;
count=p;
}
if( number>high)
break;
}
return v;
}

shivamsinha
Автор

Are we allowed to do this way this like defining answers for test cases right ?

shyamsundar
join shbcf.ru