Sequential Digits | 2 Approaches | Leetcode 1291
Vložit
- čas přidán 31. 01. 2024
- Whatsapp Community Link : www.whatsapp.com/channel/0029...
This is the 81st Video of our Playlist "Array 1D-2D : Popular Interview Problems".
In this video we will try to solve a very good Array Enumeration problem - Sequential Digits | Leetcode 1291
I will explain the intuition so easily that you will never forget and start seeing this as cakewalk EASYYY.
We will do live coding after explanation and see if we are able to pass all the test cases.
Also, please note that my Github solution link below contains both C++ as well as JAVA code.
Problem Name : Sequential Digits | Leetcode 1291
Company Tags : AMAZON
My solutions on Github(C++ & JAVA) : github.com/MAZHARMIK/Intervie...
Leetcode Link : leetcode.com/problems/sequent...
My DP Concepts Playlist : • Roadmap for DP | How t...
My Graph Concepts Playlist : • Graph Concepts & Qns -...
My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
Subscribe to my channel : / @codestorywithmik
Instagram : / codestorywithmik
Facebook : / 100090524295846
Twitter : / cswithmik
Approach-1 Summary : The first approach utilizes a queue to generate sequential digits in a breadth-first manner. It starts by enqueueing digits from 1 to 8 and then iteratively dequeues a digit, checks if it falls within the given range, and adds it to the result vector. Additionally, it enqueues the next sequential digit formed by adding one to the last digit of the current dequeued number. This process continues until the queue is empty, and the result vector contains all sequential digits within the specified range.
Approach-2 Summary : The second approach uses a precomputed list of all possible sequential digits up to nine digits in length. It then iterates through this list, filtering out numbers that are below the given low value and above the high value. The result vector is populated with the filtered numbers.
╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
╠╗║╚╝║║╠╗║╚╣║║║║║═╣
╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
✨ Timelines✨
00:00 - Introduction
#coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge#leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview#interviewtips #interviewpreparation #interview_ds_algo #hinglish #github #design #data #google #video #instagram #facebook #leetcode #computerscience #leetcodesolutions #leetcodequestionandanswers #code #learning #dsalgo #dsa #2024 #newyear
my day doesn't complete before watching your POTD video....ur way of teaching is quite amazing
Bhai travel k waqt video upload. Salute to your dedication 🔥❤️
" bhai bhai approach" was awesome 🤣
Are bhai bhai bhai approach 🤣🤣🤣🤣
Both approaches are very clear
method 1: slight change (change from recur memo to one based indexing) ese bhi likh skte hein recusrion memoisation ko
method 2:: ise pehle tabulation
slight change from tabulation to space optimization 33:44
last one was funny 😂😂,Are bhai bhai bhai...
How can anyone explain programming logic so easily.....Hats off
thanks a lot bhaiya ❣❣ Hats off to your dedication🫡, providing videos even when you are travelling ❤❤
waiting for you. ❣
and hats off to your dedication.
i solved it like this: brute force using sort
vector sequentialDigits(int low, int high) {
vector ans;
for(int i = 1; i = low && res
Interviewer be like arayy bhai bhai bhai😂😂
I just waited for your video after trying..Thanks for your efforts becoming a big fan ..☺
Best Explaination , Problem is also good i never do this type of problem of I have no idea of Intuition other then recursion.
keep making this videos will learn from u and we will be support mike
dedication level 🔥🔥🔥🔥
bhai ka samzana like "so beautiful so elegant just looking like a wow"😅
Bro LC 1247 pe ek video pls🙏🙏🙏
13:23 First approach bhi toh O(1) hi time le rhi hai , n cant exceed 36 for given constraints.
man you are awesome😂😂
are bhai bhai approach 😂
Hacker bhai 😂
🔥🔥🔥
Are bhai bhai bhai 😅👌🏻
👌👌👍👍
❤❤❤❤
❤❤❤
sir please make gfg podt today question implement Atoi explanation 😭
Bhai ek hi dil hai kitne bar jeetoge.
Ab agar koi question apne nhi kiya hota youtube pe Mai kisi or ka dekhta hi nhi chor deta hu bad me karenge😂
sir, we need one detail video on while seeing any problem Constraints on any coding paltform by seeing the Constraints we should able to think which algorithm can apply and what its time complexity, Because i am seeing that in my class top coder are first he see question statement and directly they are seen Constraints and predict which algorithm i should apply ,they know basic cp, please kindly help us sir🙏🙏..
Definitely. Noted on this.
bhaiya placement season aara hai june mai so please kuch new cheez le aoooo tadkta bhadakta like oops or something of your choice:)!!!!!
2nd approch mst h 😂
"are bhai bhai bhai"
First view
need guidance video for your videos
I did bhai bhai approach 😂
same 🤣
Bhai Bhai approach......is useful only for online assessment 😂
waiting for today's potd
czcams.com/video/LvvIcZWtuoY/video.htmlsi=HUQTNEfDaAWQaqsc ❤️❤️😇😇
A sliding window approach which beats 100% users in java
:
class Solution {
public List sequentialDigits(int low, int high) {
String nums = "123456789";
int lowerRange = 0, upperRange = 0;
int lowerTemp = low, higherTemp = high;
while (lowerTemp > 0) {
lowerTemp /= 10;
lowerRange++;
}
while (higherTemp > 0) {
higherTemp /= 10;
upperRange++;
}
List seqDigits = new ArrayList();
for (int i = lowerRange; i = low && temp
bhaiya pls try to upload this notes
like mardo sab log
bhai gfg ke count digits of a number ki bottom up video kab aayegi???
I also am waiting . I think he is travelling and will upload when he is back.
@codestorywithMIK - waiting
BFS FROM NOTHING HINT OF BFS FAIRS I THOUGHT OF DP FIRST
My approach:
class Solution {
public:
long create(int start, int size){
long res=start;
for(int i=start+1;size>0 && i=low){
ans.push_back(curNum);
}
}
curSize+=1;
}
return ans;
}
};
are bhai bhai bhai approach 🤣🤣🤣🤣
341 😳
class Solution {
public List sequentialDigits(int low, int high) {
List result = new ArrayList();
for (int i = 1; i
Beats 100%
class Solution {
public List sequentialDigits(int low2, int high2) {
int count = 0;
int low=low2,high=high2;
while(low>0)
{
low/=10;
count++;
}
int firstCount = count;
count=0;
while(high>0){
high/=10;
count++;
}
int secondCount=count;
List lis = new ArrayList();
for(int i=firstCount;i
i solved using digit dp but afterwards realized that the question was asking a vector. So there was nothing to memoize 🥲😁. But atleast this method is unique but complex and i dont know about the complexity but i guess it will be slower since i cannot memoize. Took my code (4ms)
DIGIT DP (TEMPLATE)SOLUTION
class Solution {
public:
void solve(string &R,int digit,int result,int prevDigit,int leading,bool tight,set&ans,bool erase){
if(digit == 0){
if(erase){
ans.erase(result);
return;
}
ans.insert(result);
return;
}
int ub = tight?(R[R.length()-digit]-'0'):9;
for(int i = 0;i
nice man