Remove K digits | Build lowest number | Leetcode

แชร์
ฝัง
  • เผยแพร่เมื่อ 2 ธ.ค. 2024

ความคิดเห็น • 278

  • @fullysimplified7139
    @fullysimplified7139 3 ปีที่แล้ว +17

    Can't be explained better than this... Million times thanks for making these questions so simple :)

  • @nishanksoni7120
    @nishanksoni7120 4 ปีที่แล้ว +80

    You are doing too much hard work dude.Wish you best of luck for your future endeavours.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +2

      Thanks :)

    • @gracioussaxena8318
      @gracioussaxena8318 4 ปีที่แล้ว +3

      Did you just fire the guy lol
      Great job though Tech Dose, well explained!

    • @nirajgusain1452
      @nirajgusain1452 2 ปีที่แล้ว +3

      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.🥳

    • @codingwave56
      @codingwave56 7 หลายเดือนก่อน +1

      @@nirajgusain1452 wow ! 🎉

  • @bharathik6479
    @bharathik6479 4 ปีที่แล้ว +80

    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.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +2

      Welcome :)

    • @dallasgannon5717
      @dallasgannon5717 3 ปีที่แล้ว +2

      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!

    • @johnnyzyaire602
      @johnnyzyaire602 3 ปีที่แล้ว

      @Dallas Gannon instablaster :)

    • @dallasgannon5717
      @dallasgannon5717 3 ปีที่แล้ว

      @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.

    • @dallasgannon5717
      @dallasgannon5717 3 ปีที่แล้ว +1

      @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

  • @blynch2496
    @blynch2496 4 ปีที่แล้ว +15

    Perfect, clear explanation to a problem that I've been stuck on. Thanks so much!

  • @amritanshu83
    @amritanshu83 4 ปีที่แล้ว +7

    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.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +2

      Yes....term confuses students 😅

  • @dayanandraut5660
    @dayanandraut5660 3 ปีที่แล้ว +13

    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.

  • @AmanShukla18031992
    @AmanShukla18031992 4 ปีที่แล้ว +23

    The explanation was really awesome bro. Gave a whole new perspective to look at numbers. Really appreciate the effort. Sincerely, thank you.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      Welcome :)

    • @ytg6663
      @ytg6663 2 ปีที่แล้ว

      Explain

  • @hitenarya4987
    @hitenarya4987 4 ปีที่แล้ว +6

    this channel should have millions of subs.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Thanks bro :)

    • @greatbrothers2947
      @greatbrothers2947 3 ปีที่แล้ว

      This channel work so hard i wish this channel should have millions of subscribers

  • @sundeep1501
    @sundeep1501 4 ปีที่แล้ว +3

    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

    • @yadneshkhode3091
      @yadneshkhode3091 3 ปีที่แล้ว

      your time complexity is N^2 and space complexity is also N

  • @0anant0
    @0anant0 4 ปีที่แล้ว

    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.

  • @sudhanshuverma1987
    @sudhanshuverma1987 2 ปีที่แล้ว +3

    Awesome explanation. You’re doing a great job in helping the community.

  • @ShubhamSharma1210
    @ShubhamSharma1210 4 ปีที่แล้ว +2

    nice .. this is a good explanation. the good part is you are telling more examples that make more sense for everyone.

  • @yitingg7942
    @yitingg7942 3 ปีที่แล้ว +2

    This is absolutely mind blowing. Couldn't think of this approach.. 😭😭😭 Also so many edges cases to handle... But great great video.

  • @shivangshukla4243
    @shivangshukla4243 4 ปีที่แล้ว +5

    God level explanation bro. Been watching your videos since a month and they are all brilliant. Will definitely donate once I land a job :)

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Thanks for your appreciation.

  • @santoshreddy3
    @santoshreddy3 3 ปีที่แล้ว +1

    Your explanations are best I have found on TH-cam.

  • @bhavyapandey
    @bhavyapandey 3 ปีที่แล้ว +1

    An inspiration for anyone who wishes to learn or teach DSA

  • @aamirjamal6833
    @aamirjamal6833 3 ปีที่แล้ว +3

    I wish I could like this video more than once. Thanks for your explanation. You are good!

  • @sameera2426
    @sameera2426 7 หลายเดือนก่อน

    It was such a great explanation. Half way through the video and I knew what to do. Keep up the good work.

  • @xapeuuu
    @xapeuuu 4 ปีที่แล้ว +6

    Glad i got the stack approach by myself even though my code was way messier than yours ^^

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +2

      Many were not able to solve this. Glad that you did :)

    • @PhenomenalInitiations
      @PhenomenalInitiations 3 ปีที่แล้ว

      Can you please explain why in line 15 he consiered only when stack is not empty?

  • @culeforever5408
    @culeforever5408 11 หลายเดือนก่อน +1

    great explaination

  • @harkitnebamake
    @harkitnebamake 3 ปีที่แล้ว +3

    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)

  • @akashsingha2616
    @akashsingha2616 4 ปีที่แล้ว +2

    Great explanation brother. Understood each and every step. Keep doing great work.

  • @lanpingdeng1094
    @lanpingdeng1094 4 ปีที่แล้ว +2

    great explanation, easy to follow and understand. thanks

  • @anshimagarg9661
    @anshimagarg9661 4 ปีที่แล้ว +1

    I'm so happy that I found your video. I understood it very well. Thank you very much sir.

  • @azadsingh8466
    @azadsingh8466 2 ปีที่แล้ว +2

    Dude, congrats on 100K. You deserve it

  • @AyushRaj-gf2ce
    @AyushRaj-gf2ce 4 ปีที่แล้ว +1

    extremly datailed explanation..thank you so much!!

  • @dhruvvarshney1040
    @dhruvvarshney1040 3 ปีที่แล้ว +2

    kya baap tarike se sikhaya bhai. Mja aagya. Thanks man

  • @Darshil1771
    @Darshil1771 4 ปีที่แล้ว +1

    Became fan of your explanation! Much much appreciated!

  • @ujjvalsharma5055
    @ujjvalsharma5055 4 ปีที่แล้ว

    wonderful video. Great explanation of code and intuition. Keep up the good work

  • @spetsnaz_2
    @spetsnaz_2 4 ปีที่แล้ว +2

    starting the day with your video

  • @agileprogramming7463
    @agileprogramming7463 4 ปีที่แล้ว +4

    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.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      It could have been dp problem if you thought about recursively solving this.

  • @kaichenghu3826
    @kaichenghu3826 4 ปีที่แล้ว +1

    Very good explanation and visualization

  • @suryanshgupta7518
    @suryanshgupta7518 3 ปีที่แล้ว +1

    wonderfull way of explaining..

  • @harishvemula6709
    @harishvemula6709 4 ปีที่แล้ว +2

    Sir , the way you explain is absolutely amazing !! . Wish i had a teacher like you . Greatwork Sir !! :) :)

  • @satyakidas7297
    @satyakidas7297 2 ปีที่แล้ว

    Amazing intuition explained. Thank you

  • @red_and_black_UA
    @red_and_black_UA 3 ปีที่แล้ว +1

    great job, thanks for good quality of explanation

  • @kkgirl543
    @kkgirl543 4 ปีที่แล้ว +2

    This is an amazing explanation! Nice question, thanks.

  • @thelimit9719
    @thelimit9719 3 ปีที่แล้ว +2

    Perfect implementation !!

  • @SaiKiran-dy6ke
    @SaiKiran-dy6ke 4 ปีที่แล้ว +2

    Man, wonderful explanation.. Highly appreciated.. 💞💞

  • @samridhshubham8109
    @samridhshubham8109 ปีที่แล้ว

    Wat an explanation, absolute gem

  • @collegeworld7494
    @collegeworld7494 ปีที่แล้ว

    Best concise explanation

  • @paragroy5359
    @paragroy5359 11 หลายเดือนก่อน

    Nice content.
    Keep on making such videos

  • @jashhinger442
    @jashhinger442 ปีที่แล้ว +1

    Great explanation sir, Thanku so much

  • @asliddinburiev5143
    @asliddinburiev5143 2 ปีที่แล้ว

    Simple and perfect explanation!

  • @vaalarivan_p
    @vaalarivan_p 2 ปีที่แล้ว +1

    0:00 - 8:59

  • @RahulKumar-oj4lz
    @RahulKumar-oj4lz 3 ปีที่แล้ว +1

    Great Explanation

  • @hapysethi1306
    @hapysethi1306 4 ปีที่แล้ว +1

    Bhai thanks alot for sharing
    Algo
    Code and
    Explanation

  • @shrijonbiswas8105
    @shrijonbiswas8105 ปีที่แล้ว

    This is a phenomenal explanation!!

  • @rajeshbammidy180
    @rajeshbammidy180 4 ปีที่แล้ว +2

    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

  • @adarshsasidharan254
    @adarshsasidharan254 2 ปีที่แล้ว

    man what a brilliant explanation

  • @karansagar7870
    @karansagar7870 4 ปีที่แล้ว +1

    Great approach

  • @nikhillingam4630
    @nikhillingam4630 4 ปีที่แล้ว +1

    Best explanations ever

  • @niteenautade
    @niteenautade 2 ปีที่แล้ว

    Beautifully explained.

  • @himangshushekharjha6972
    @himangshushekharjha6972 4 ปีที่แล้ว +1

    Simply Awesome! Keep Growing!!

  • @sanketsuryawanshi
    @sanketsuryawanshi 4 ปีที่แล้ว +1

    Very Well Explained sir 🔥👍🏻

  • @anuplohar23
    @anuplohar23 8 หลายเดือนก่อน

    Nice Explanation

  • @rahulchaubey8988
    @rahulchaubey8988 4 ปีที่แล้ว +1

    Nicely explained..

  • @jolly_dollyyy
    @jolly_dollyyy 2 ปีที่แล้ว +1

    Lucid Explanation!!

  • @codesnippets03
    @codesnippets03 4 ปีที่แล้ว +1

    Amazing 👌 explaination

  • @vishalbhatane1608
    @vishalbhatane1608 4 ปีที่แล้ว +2

    Thank you very much!

  • @anil7931
    @anil7931 4 ปีที่แล้ว +1

    Thanks for clear explanation !!

  • @HarishAmarnath
    @HarishAmarnath 4 ปีที่แล้ว

    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

  • @kushgupta1187
    @kushgupta1187 4 ปีที่แล้ว +1

    Very well explained

  • @abhishektanwar7902
    @abhishektanwar7902 4 ปีที่แล้ว +1

    Amazing👌

  • @Shubham-zu1zh
    @Shubham-zu1zh ปีที่แล้ว

    good explaination

  • @crankyinmv
    @crankyinmv 4 ปีที่แล้ว +1

    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.

  • @deepeshdragoneel3351
    @deepeshdragoneel3351 4 ปีที่แล้ว +2

    Wow such a beautiful problem!

  • @abhishek__anand__
    @abhishek__anand__ ปีที่แล้ว

    Great Video

  • @akhilesh59
    @akhilesh59 2 ปีที่แล้ว

    Nice Explanation! Thank you 😄

  • @aakashbhatia
    @aakashbhatia 2 ปีที่แล้ว

    good explanation

  • @vaishnavikulkarni8104
    @vaishnavikulkarni8104 4 ปีที่แล้ว +1

    Amazing sir

  • @Arunkumar-pg8kx
    @Arunkumar-pg8kx 3 ปีที่แล้ว +1

    That was amazing,

  • @sleepypanda7172
    @sleepypanda7172 2 ปีที่แล้ว

    pure genius!

  • @madhavsahi7400
    @madhavsahi7400 4 ปีที่แล้ว +2

    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 ...

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      Removing leading zeroes are not counted as removed digits. This is the special case to be handled 😅

    • @pranavgautam1958
      @pranavgautam1958 4 ปีที่แล้ว +1

      1st valley(4-3) 2nd (3-0) 3rd(1-0) 4th(6-2) so, we get -0120

    • @saianushachodapaneedi7504
      @saianushachodapaneedi7504 4 ปีที่แล้ว

      Even I got the same doubt...what's wrong if 0 also added in stack...then output will be 0120.. please clarify my doubt

    • @nikkig333
      @nikkig333 4 ปีที่แล้ว

      @@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.

  • @abhishekrai4325
    @abhishekrai4325 4 ปีที่แล้ว +2

    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 💙

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +3

      You love and motivation is everything I need :)

    • @abhishekrai4325
      @abhishekrai4325 4 ปีที่แล้ว +1

      @@techdose4u We love you 3000 Sir 🥺 keep up the good work and we'll always make you proud.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Thanks :)

  • @luanaamorim5055
    @luanaamorim5055 4 ปีที่แล้ว +1

    thanks so much, great explanation!

  • @ninehoursful
    @ninehoursful 4 ปีที่แล้ว +1

    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.

  • @vm1662
    @vm1662 4 ปีที่แล้ว +1

    Amazing stuff! Thank you.

  • @secularph8424
    @secularph8424 4 ปีที่แล้ว +1

    I was waiting for your explanation,

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      :) This video was little longer and I was very tired after office 😅

    • @secularph8424
      @secularph8424 4 ปีที่แล้ว +1

      @@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
      😂😘😘

    • @ojobabatunde8415
      @ojobabatunde8415 4 ปีที่แล้ว +1

      As in, so i was

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      😅

    • @spetsnaz_2
      @spetsnaz_2 4 ปีที่แล้ว +1

      me tooo....

  • @ritikthakur2445
    @ritikthakur2445 4 ปีที่แล้ว +1

    nice explanation ❤❤

  • @ShubhamSingh-fl3qi
    @ShubhamSingh-fl3qi 4 ปีที่แล้ว +1

    This helps alot ThankYou sir

  • @sachinduhan3022
    @sachinduhan3022 4 ปีที่แล้ว +1

    amazing explanations man...

  • @sparrowsurya96
    @sparrowsurya96 3 ปีที่แล้ว

    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

  • @anshshah4927
    @anshshah4927 4 ปีที่แล้ว +1

    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?

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      C++ has lower runtime in general. So go with C++

  • @rohits22013
    @rohits22013 4 ปีที่แล้ว +1

    good explanation man

  • @rajnisharyan6361
    @rajnisharyan6361 4 ปีที่แล้ว

    hey, can you please tell me about how you are wrinting are you using digital pen and which software you are using for writing

  • @aswadk
    @aswadk 4 ปีที่แล้ว +1

    Too Good!

  • @ojobabatunde8415
    @ojobabatunde8415 4 ปีที่แล้ว +2

    Thanks man

  • @vishnuparegi4580
    @vishnuparegi4580 4 ปีที่แล้ว +2

    👌

  • @oladimejijames9554
    @oladimejijames9554 4 ปีที่แล้ว

    nice work sir, please keep it up. Kudos

  • @kongzilla2897
    @kongzilla2897 3 ปีที่แล้ว

    Nice and clean :)

  • @tirthjayswal9895
    @tirthjayswal9895 4 ปีที่แล้ว

    Good

  • @gauravkumarpandit7022
    @gauravkumarpandit7022 4 ปีที่แล้ว +1

    please make a video on heavy light decomposition and centroid decomposition

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว

      Sure....will add it to my to-do list

  • @srini580
    @srini580 3 ปีที่แล้ว +1

    Thank You Sir!

  • @Amit_Kumar_1999
    @Amit_Kumar_1999 4 ปีที่แล้ว +1

    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.

    • @techdose4u
      @techdose4u  4 ปีที่แล้ว +1

      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 😅

  • @istiyakahmed4117
    @istiyakahmed4117 4 ปีที่แล้ว +1

    nice explanation! keep it up :D

  • @karthikchandra7303
    @karthikchandra7303 2 ปีที่แล้ว

    Hi sir amazing explanation the method looked very nice, but i dont think it will work for numbers with trailing zeros in the end

  • @marlegagaming1274
    @marlegagaming1274 3 ปีที่แล้ว +3

    Nice, but how can you get such idea in an interview ?

  • @heroicrhythms8302
    @heroicrhythms8302 ปีที่แล้ว

    I've been into problem-solving for over a year, and this is the best channel I have seen.
    the channel is better than Love Babbar, TUF, Anuj Bhayya, and all the members out there

  • @anands9407
    @anands9407 4 ปีที่แล้ว +1

    helpful!