Wonderful way of explaining the algorithm behind the program. Most channels only explain(show) the code. Please keep up this great work. Please do mostly asked Leetcode medium questions. Will be a great help. Thanks a lot.
Sorry to be off topic but does any of you know of a way to log back into an Instagram account..? I stupidly forgot the account password. I would appreciate any tips you can give me!
@Johnny Zyaire I really appreciate your reply. I found the site thru google and im in the hacking process now. Takes quite some time so I will reply here later when my account password hopefully is recovered.
One of the best intuitions I have ever seen. I love the way you take examples to derive the logic. Keep it up. And also thanks for delivering such a quality content on coding problems. You just earned a subscriber.
Very nice explanation better than other explanations out there which just throw terms like greedy etc. Giving concrete examples and explaining the algo through them makes it much easier to understand.
Your explanation is really good and with O(N) which is better. I solved this problem with different approach and I think the time complexity id O(N * k). Is that correct? Step 1: Parse the string left to right. Step 2: For each current char at i, See if there is a char lesser than the current char in window [i+1 to i+k]. If found, decrement the k and skip the char. Otherwise add to the result. Here is the code: public String removeKdigits(String num, int k) { if(num == null || num.length() == 0 || num.length() 0){ builder.delete(builder.length()-rem, builder.length()); } String res = builder.toString(); return res.length() == 0? "0" : res; } int getMinIndex(char val, int start, int end, String num){ if(end >= num.length()){ return -1; } for(int i = start; i
Awesome explanation! Thanks! As per the explanation, just remember this: Remove previously seen peak elem to flatten the curve. When graph dips, we have already seen a peak.
Pretty good explaination bro ! I was able to solve it in my mind but couldn't put it in code . DIdn't think about first-come maxima approach . Cheers (y)
Initially I thought this is a DP problem because I thought we have to consider all possible cases and the do the DP thing... but this approach is really wonderful.
One thing to notice here if the elements keeps on increasing as he said it will form the smallest number possible that means we will have the higer value digits at the end so we can remove them easily with the help of the stack
I got a goodone idea to solve this say we have the number 71382 and k=2 so what we can do is that to divide the digit by its index number, index number must be starting from 0 ie for 7 index number should be 1 not 0 and so on,, then after we got the list of the divided result we can just chose the minimums possible and then we can include only those in return value, me testing this got all correct result for almost all cases
How does one come up with such intuitive solutions? I tried to come up with multiple solutions but was not even close to this solution. I tried to solve this question using priorityQueue, HashMaps, expanding from center of the string.
Thanks. I hate your 4's but the overall the video was quite helpful. I solved 402 with a different approach, but wanted to see how the stack based approach worked. No I know.
Sir ji aap great ho. Is there any way we can contribute even a little towards your hard work ?? Sir please let us know. And again, thank you so much for such a wonderful explanation 💙
do you have any sort of material which can give proof of these algorithms? like build the lowest number & finding the next permutation. Though I know how to solve these problems, but I stuck at proof.
No material available with me. I don't think we need proof for simple problems like these. For complex problems there is confusion and when we don't really understand why the given algo works then proof is required. But I don't think this problem requires it 😅
I was also approching the same way, but stuck in one TC i.e "1234567890" where k=9 op = "0" this will give output 1 according to this approch. Correct me if i am wrong
Can this be solved using some variation of knapsack , considering size =n-k , values 1 4 3 7 2 9 , as each digit may come or may not come in the solution .
How do you recognize that this question can be solved by monotonic stack? I'm completely blank after seeing this question!. Only thought came to my mind is of dp, but seeing the constraints killed my initial thought of dp.
I am a bit confused about this problem. lets say we have the number 143. When we delete 4, 1 takes its place since the new number will be 13 and 1 is in the tens place where 4 was. So why do we look at the number right of the number we delete if the left number takes its place?
If the problem statement is reversed and we have to find the maximum number after deleting k digits, would we do the opposite by looking for where it rises instead of dips from left to right?
In 10:58 , what if the next element of zero is 2 Instead of 1 , then our results first number should be 1 . But we would have already removed it . I think it will fail for that scenario
@@techdose4u its okay Usually, I complete the task in the noon and compare our solutions in the night But this i couldn't do it, so I was waiting for your solution 😂😘😘
Sir the example at 12:00 mins of number 14301620 Nd k=4...the answer if the think on pen n paper should be 1010....but why it is 120 ?.... technically thinking the answer should be 1010 after removing 4 digits ...
@@saianushachodapaneedi7504 If you add 0 in stack, while displaying result it will have leading 0, in the example shown by LC they removed leading zeroes so we can ignore leading 0s as mentioned here or parse the string integer and back to string so that leading 0s are gone. In order not to put extra effort, ignoring leading zeroes will suffice the requirement.
You are doing too much hard work dude.Wish you best of luck for your future endeavours.
Thanks :)
Did you just fire the guy lol
Great job though Tech Dose, well explained!
Hey there, I am from year 2022, I came back in time to give you good news that ,Surya sir(tech dose founder) has joined Google.🥳
@@nirajgusain1452 wow ! 🎉
Can't be explained better than this... Million times thanks for making these questions so simple :)
Wonderful way of explaining the algorithm behind the program. Most channels only explain(show) the code. Please keep up this great work. Please do mostly asked Leetcode medium questions. Will be a great help. Thanks a lot.
Welcome :)
Sorry to be off topic but does any of you know of a way to log back into an Instagram account..?
I stupidly forgot the account password. I would appreciate any tips you can give me!
@Dallas Gannon instablaster :)
@Johnny Zyaire I really appreciate your reply. I found the site thru google and im in the hacking process now.
Takes quite some time so I will reply here later when my account password hopefully is recovered.
@Johnny Zyaire it did the trick and I now got access to my account again. Im so happy!
Thanks so much you saved my account :D
Perfect, clear explanation to a problem that I've been stuck on. Thanks so much!
Welcome :)
One of the best intuitions I have ever seen. I love the way you take examples to derive the logic. Keep it up. And also thanks for delivering such a quality content on coding problems. You just earned a subscriber.
Thanks
Very nice explanation better than other explanations out there which just throw terms like greedy etc. Giving concrete examples and explaining the algo through them makes it much easier to understand.
Yes....term confuses students 😅
The explanation was really awesome bro. Gave a whole new perspective to look at numbers. Really appreciate the effort. Sincerely, thank you.
Welcome :)
Explain
Your explanation is really good and with O(N) which is better.
I solved this problem with different approach and I think the time complexity id O(N * k). Is that correct?
Step 1: Parse the string left to right.
Step 2: For each current char at i, See if there is a char lesser than the current char in window [i+1 to i+k]. If found, decrement the k and skip the char. Otherwise add to the result.
Here is the code:
public String removeKdigits(String num, int k) {
if(num == null || num.length() == 0 || num.length() 0){
builder.delete(builder.length()-rem, builder.length());
}
String res = builder.toString();
return res.length() == 0? "0" : res;
}
int getMinIndex(char val, int start, int end, String num){
if(end >= num.length()){
return -1;
}
for(int i = start; i
your time complexity is N^2 and space complexity is also N
This is absolutely mind blowing. Couldn't think of this approach.. 😭😭😭 Also so many edges cases to handle... But great great video.
God level explanation bro. Been watching your videos since a month and they are all brilliant. Will definitely donate once I land a job :)
Thanks for your appreciation.
this channel should have millions of subs.
Thanks bro :)
This channel work so hard i wish this channel should have millions of subscribers
Awesome explanation. You’re doing a great job in helping the community.
I wish I could like this video more than once. Thanks for your explanation. You are good!
Thanks 😊
Awesome explanation! Thanks! As per the explanation, just remember this: Remove previously seen peak elem to flatten the curve. When graph dips, we have already seen a peak.
Pretty good explaination bro !
I was able to solve it in my mind but couldn't put it in code .
DIdn't think about first-come maxima approach .
Cheers (y)
Nice
nice .. this is a good explanation. the good part is you are telling more examples that make more sense for everyone.
Thanks :)
It was such a great explanation. Half way through the video and I knew what to do. Keep up the good work.
Your explanations are best I have found on RUclips.
Thanks :)
Glad i got the stack approach by myself even though my code was way messier than yours ^^
Many were not able to solve this. Glad that you did :)
Can you please explain why in line 15 he consiered only when stack is not empty?
kya baap tarike se sikhaya bhai. Mja aagya. Thanks man
❤️
An inspiration for anyone who wishes to learn or teach DSA
👍🏼
Initially I thought this is a DP problem because I thought we have to consider all possible cases and the do the DP thing... but this approach is really wonderful.
It could have been dp problem if you thought about recursively solving this.
wonderfull way of explaining..
Thanks :)
Dude, congrats on 100K. You deserve it
Welcome 😄
Great explanation sir, Thanku so much
Welocome :)
One thing to notice here if the elements keeps on increasing as he said it will form the smallest number possible that means we will have the higer value digits at the end so we can remove them easily with the help of the stack
Yes correct :)
Nice content.
Keep on making such videos
I'm so happy that I found your video. I understood it very well. Thank you very much sir.
Welcome :)
wonderful video. Great explanation of code and intuition. Keep up the good work
Great explanation brother. Understood each and every step. Keep doing great work.
Thanks :)
great explanation, easy to follow and understand. thanks
Welcome :)
Sir , the way you explain is absolutely amazing !! . Wish i had a teacher like you . Greatwork Sir !! :) :)
Thanks :)
Became fan of your explanation! Much much appreciated!
Thanks :)
Amazing intuition explained. Thank you
I got a goodone idea to solve this say we have the number 71382 and k=2 so what we can do is that to divide the digit by its index number, index number must be starting from 0 ie for 7 index number should be 1 not 0 and so on,, then after we got the list of the divided result we can just chose the minimums possible and then we can include only those in return value, me testing this got all correct result for almost all cases
extremly datailed explanation..thank you so much!!
Welcome :)
Very good explanation and visualization
Thanks
hey, can you please tell me about how you are wrinting are you using digital pen and which software you are using for writing
great job, thanks for good quality of explanation
Welcome 😊
Wat an explanation, absolute gem
starting the day with your video
;D
How does one come up with such intuitive solutions? I tried to come up with multiple solutions but was not even close to this solution.
I tried to solve this question using priorityQueue, HashMaps, expanding from center of the string.
great explaination
Simple and perfect explanation!
Man, wonderful explanation.. Highly appreciated.. 💞💞
Thanks :)
Thanks. I hate your 4's but the overall the video was quite helpful.
I solved 402 with a different approach, but wanted to see how the stack based approach worked. No I know.
😅
Bhai thanks alot for sharing
Algo
Code and
Explanation
Welcome :)
This is an amazing explanation! Nice question, thanks.
Welcome :)
Best concise explanation
Sir ji aap great ho. Is there any way we can contribute even a little towards your hard work ?? Sir please let us know. And again, thank you so much for such a wonderful explanation 💙
You love and motivation is everything I need :)
@@techdose4u We love you 3000 Sir 🥺 keep up the good work and we'll always make you proud.
Thanks :)
This is a phenomenal explanation!!
Beautifully explained.
man what a brilliant explanation
Great Explanation
Thanks 😊
Simply Awesome! Keep Growing!!
Thanks :)
Perfect implementation !!
Thanks :)
Nice Explanation! Thank you 😄
Very Well Explained sir 🔥👍🏻
Thanks :)
Nice, but how can you get such idea in an interview ?
Practice :)
Thanks for clear explanation !!
Welcome :)
do you have any sort of material which can give proof of these algorithms? like build the lowest number & finding the next permutation. Though I know how to solve these problems, but I stuck at proof.
No material available with me. I don't think we need proof for simple problems like these. For complex problems there is confusion and when we don't really understand why the given algo works then proof is required. But I don't think this problem requires it 😅
Lucid Explanation!!
Thanks 😊
Man you are doing very good work keep it up
Also I did the same in C but C is very messy TBH should I go for c++ or python?
C++ has lower runtime in general. So go with C++
Hi sir amazing explanation the method looked very nice, but i dont think it will work for numbers with trailing zeros in the end
I was also approching the same way, but stuck in one TC i.e "1234567890" where k=9
op = "0" this will give output 1 according to this approch. Correct me if i am wrong
nice work sir, please keep it up. Kudos
Thanks :)
Wow such a beautiful problem!
good explaination
Can this be solved using some variation of knapsack , considering size =n-k , values 1 4 3 7 2 9 , as each digit may come or may not come in the solution .
Best explanations ever
Thanks :)
Thank you very much!
Welcome :)
thanks so much, great explanation!
Thanks
please make a video on heavy light decomposition and centroid decomposition
Sure....will add it to my to-do list
How do you recognize that this question can be solved by monotonic stack? I'm completely blank after seeing this question!. Only thought came to my mind is of dp, but seeing the constraints killed my initial thought of dp.
👌
👍
Nice Explanation
great explanation
plzz make a video on create maximum number of leetcode.It is one of the hardest problem of leetcode and no solution is present
Will do it later. Not in MAY atleast. Hope leetcode doesn't extend the challenge to June 😅
Can we use butmasking to reduce complexity to o(n)
good explanation
I am a bit confused about this problem. lets say we have the number 143. When we delete 4, 1 takes its place since the new number will be 13 and 1 is in the tens place where 4 was. So why do we look at the number right of the number we delete if the left number takes its place?
Amazing stuff! Thank you.
Welcome :)
Great approach
Thanks :)
Amazing 👌 explaination
Thanks :)
If the problem statement is reversed and we have to find the maximum number after deleting k digits, would we do the opposite by looking for where it rises instead of dips from left to right?
pure genius!
Great Video
In 10:58 , what if the next element of zero is 2 Instead of 1 , then our results first number should be 1 . But we would have already removed it . I think it will fail for that scenario
Nicely explained..
Thanks:)
This helps alot ThankYou sir
Welcome :)
Very well explained
Thanks :)
amazing explanations man...
Thanks :)
I was waiting for your explanation,
:) This video was little longer and I was very tired after office 😅
@@techdose4u its okay
Usually, I complete the task in the noon and compare our solutions in the night
But this i couldn't do it, so I was waiting for your solution
😂😘😘
As in, so i was
😅
me tooo....
Sir the example at 12:00 mins of number 14301620 Nd k=4...the answer if the think on pen n paper should be 1010....but why it is 120 ?.... technically thinking the answer should be 1010 after removing 4 digits ...
Removing leading zeroes are not counted as removed digits. This is the special case to be handled 😅
1st valley(4-3) 2nd (3-0) 3rd(1-0) 4th(6-2) so, we get -0120
Even I got the same doubt...what's wrong if 0 also added in stack...then output will be 0120.. please clarify my doubt
@@saianushachodapaneedi7504 If you add 0 in stack, while displaying result it will have leading 0, in the example shown by LC they removed leading zeroes so we can ignore leading 0s as mentioned here or parse the string integer and back to string so that leading 0s are gone. In order not to put extra effort, ignoring leading zeroes will suffice the requirement.
Thanks
Welcome
That was amazing,
Thanks :)
nice explanation! keep it up :D
Thanks :)
Bhaiya you are amazing !! Are you in linkedin ??
Obviously. You can get profile link from my channel. From next video onwards, I will add my LinkedIn handle in description :)
@@techdose4u Thanks bhaiya ✨
Nice and clean :)
Thank You Sir!
Welcome :)