Remove K Digits | Intuition | Dry Run | Leetcode 402 | codestorywithMIK

Поділитися
Вставка
  • Опубліковано 27 сер 2024

КОМЕНТАРІ • 146

  • @wearevacationuncoverers
    @wearevacationuncoverers 4 місяці тому +36

    Stack jaae bhaad me. 🤣🤣🤣
    Koi aapki tarah parha nahi sakta bhai. love you

  • @ankanbrahmachary6581
    @ankanbrahmachary6581 4 місяці тому +10

    explaining code is for kids ..Legends build intuition from ground up .. 🔥🔥🔥🔥🔥🔥"bhadme jae stack"

  • @pokeindia5361
    @pokeindia5361 2 місяці тому +1

    Best video of entire DSA community among all DSA channels in youtube..

  • @yourcoderboy
    @yourcoderboy 4 місяці тому +11

    Love from Bangladesh ❤️

  • @theoffshoregaming
    @theoffshoregaming 4 місяці тому +19

    Thumbnail khtrnaak h bhai😂😂

  • @gauravbanerjee2898
    @gauravbanerjee2898 4 місяці тому +3

    Literally itna details mei youtube mei time leke koi nahi padhata, direct approach batake 10-20 mins mei video khatam kar dete hai . Thanks a lot bhaiya for your efforts Love you 3000❤❤ and Eid mubarak❤🌙✨

  • @atulkumarpandey3342
    @atulkumarpandey3342 4 місяці тому +3

    Bhai ekdm crystal clear samjhate ho, Love you brother ❤❤

  • @akshanshsharma6025
    @akshanshsharma6025 4 місяці тому +1

    bhai maine kam se kam 10 article padhe par kahi bhi intution nahi mili phir last m video dekhi aur inution samzi aur code khud se likh liya heads off you brother

  • @RishabhChatterjee-fg2gz
    @RishabhChatterjee-fg2gz 12 днів тому +1

    Awesome explanation ❤❤

  • @devshubham5528
    @devshubham5528 2 місяці тому +2

    amazing explanation, subscribe to banta hai (done✅)

  • @sadafkausar8770
    @sadafkausar8770 4 місяці тому +6

    Eid Mubarak bhayya 🌙 🌙
    You are soo good making vedio for us on this day also .

  • @cllabnatin5121
    @cllabnatin5121 29 днів тому +1

    Waah explaination better than striver, Great brother you made every problem looks easy.

    • @harshitshrivas5444
      @harshitshrivas5444 22 дні тому +1

      He teaches good and explain very nice .. but there is no comparison of striver 😊

    • @RishabhChatterjee-fg2gz
      @RishabhChatterjee-fg2gz 12 днів тому +1

      ​@@harshitshrivas5444 striver bhai is question ko direct stack mein intuition build karaya isiliye bol rage hai

    • @harshitshrivas5444
      @harshitshrivas5444 12 днів тому

      @@RishabhChatterjee-fg2gz if you are know some about coding and then you practice striver he is best because its question choice and all are no comparison. He explained well no doubt but why comparing with the person with best playlist all over UA-cam tuf and tuf+

  • @mursalinhawlader6407
    @mursalinhawlader6407 4 місяці тому +1

    you deserve more subscriber

  • @paveshkanungo6338
    @paveshkanungo6338 4 місяці тому +1

    Your videos are toooooo good.
    Many students are with youuu.
    🤯🤯🤯💥💥💥💥💥💥💥💥💥💥

  • @kareni7572
    @kareni7572 3 місяці тому +1

    Amazing! This place value is similar to “Next greater element III”

  • @labadepradip7734
    @labadepradip7734 4 місяці тому +2

    aaj pata chala ki school ke basics kis tarah se use kar sakate hai is question me aur monotonic ka dr khatam ho gaya
    🙂🙃

  • @manassalunke1755
    @manassalunke1755 Місяць тому +1

    Thanks bro, great work.

  • @Sahilsharma-sk5vr
    @Sahilsharma-sk5vr 2 місяці тому +1

    keep making videos like this .

  • @ananttripathi4023
    @ananttripathi4023 Місяць тому

    Bro ur content quality is soo soo much good.

  • @32bhogawaraniketanil82
    @32bhogawaraniketanil82 4 місяці тому

    I always love ❤ the way you explain the question, the intuition, and then the code.. Thank you very much for such amazing content.

  • @fshimcds
    @fshimcds 4 місяці тому +1

    Best Teacher ever😊

  • @rohanpagare3786
    @rohanpagare3786 4 місяці тому +1

    bhai, bohot sahi explanation kiya he aapne, thank you bhai.

  • @hemendrachaudhary3263
    @hemendrachaudhary3263 4 місяці тому +2

    bhaiii yar tum aadmi OP ho

  • @biswarupacharjya2258
    @biswarupacharjya2258 4 місяці тому +1

    you are my best teacher

  • @Virtualexist
    @Virtualexist 29 днів тому +2

    Niceee!
    I implemented it on my own using the approach, but I modified original input instead.
    string removeKdigits(string num, int k) {
    for(int i =0; i(int)num[i+1] && k>0 )
    {
    num.erase(i,1);
    i--;
    k--;
    }
    else i++;
    // agar index out of bound chale gaye less than 0 toh..
    if(i0)
    num = num.substr(0,num.size()-k);
    // just to remove leading zeros
    int leading = 0;
    while (num[leading] == '0')
    leading++;
    if(leading)
    num.erase(0, leading);

    // agar sabhi kuch remove ho raha hai, toh..
    if(!num.size()) num = "0";
    return num;
    }

  • @ajinkyakhete1151
    @ajinkyakhete1151 4 місяці тому

    I don't know you will read my comment or not but your explanations are the best, literally your tone of speaking , interaction with audience. Literally I have don't have words to say hats off brother .... Keep it up ☺️

  • @AnjuGupta-sz1uk
    @AnjuGupta-sz1uk 4 місяці тому

    Really liked this approach of solving this problem... Bhaiya you are great , your explanations are best😊

  • @devgupta7290
    @devgupta7290 4 місяці тому +1

    crazy explanation best one hands down
    🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥

  • @gui-codes
    @gui-codes 4 місяці тому

    Truly the Intuition God

  • @ayaanrashid960
    @ayaanrashid960 4 місяці тому +1

    Eid Mubarak Bhai 🌙

  • @raftywate
    @raftywate 4 місяці тому +1

    Eid mubarak, bhaijaan!🌛

  • @aryangupta-sv8vb
    @aryangupta-sv8vb 4 місяці тому

    nice yaar.. really aaj frustate hi hi gya tha

  • @Chitranshu972
    @Chitranshu972 4 місяці тому

    Best Explanation

  • @chethangowdahr7653
    @chethangowdahr7653 4 місяці тому

    bro, ur explanation is very good... nice video

  • @MEBSonukumar
    @MEBSonukumar 4 місяці тому +1

    thank you bhai for clearing T.C. Confusion

  • @ayoobraza8790
    @ayoobraza8790 4 місяці тому

    Sir we need this type Intuition it's great 👍 100% understand basic to advance thanks you Sir

  • @RishabhDhiman-zf5wd
    @RishabhDhiman-zf5wd 4 місяці тому

    Really great way to explain and approach problem 🙌🙌.

  • @tanujamehra608
    @tanujamehra608 4 місяці тому +1

    It really helps me

  • @YashSinghal
    @YashSinghal 4 місяці тому

    your intuition explanations are best!

  • @nikhilhaspe2734
    @nikhilhaspe2734 4 місяці тому

    amazing Guru!

  • @subhajitdey135
    @subhajitdey135 4 місяці тому

    Hats off to your explanation ❤

  • @rushikesh_nale07
    @rushikesh_nale07 4 місяці тому

    BESTESTT EXPLAINATION!❤❤❤

  • @EB-ot8uu
    @EB-ot8uu 4 місяці тому +1

    you are legit bro.

  • @yogeshchauhan9401
    @yogeshchauhan9401 4 місяці тому +3

    Very Intuitive Solution 👍👍Can you upload leetcode 729 too ?😅

  • @study-yd6es
    @study-yd6es 4 місяці тому +1

    Amazing Explainationssss ❣❣

  • @akbar55555shaikh
    @akbar55555shaikh 4 місяці тому +1

    you simply beat the explanation of all other UA-cam channels.
    All teach how to solve the problem, but you show how to build it.
    In your case, DS comes later because that can be self-understood which DS to use.

  • @advitkothari7302
    @advitkothari7302 Місяць тому +1

    gr8!!

  • @swagboltey102
    @swagboltey102 4 місяці тому +1

    Eid Mubarak ✨ Bhai ❤️

  • @JatinGupta-ze6nc
    @JatinGupta-ze6nc 4 місяці тому

    thanks bhai for making me consistent

  • @closer9689
    @closer9689 4 місяці тому +2

    Aaj lga ki code krna bhi entertaining ho skta hai>>>
    Kyoki Nyi Nyi stories sunna kisko nhi Pasand😂

    • @codestorywithMIK
      @codestorywithMIK  4 місяці тому

      So guys, “Aao, story se code likhe” 😁❤️

  • @ugcwithaddi
    @ugcwithaddi 4 місяці тому +1

    Was waiting 🎉for

  • @vishalsisodiya28
    @vishalsisodiya28 4 місяці тому +1

    Thank u so much bhaiya ❤

  • @kunalpatil.24
    @kunalpatil.24 4 місяці тому +2

    Stack jaae bhaad me. 😂
    Thank You!

  • @dhruvrawat7023
    @dhruvrawat7023 4 місяці тому

    class Solution {
    public:
    string removeKdigits(string num, int k) {
    string fa = "";
    int n = num.size();
    for(int i = 0; i < n; i++){
    while(fa.size() > 0 && fa.back() > num[i] && k > 0){
    fa.pop_back();
    k--;
    }
    if(fa.size() > 0 || num[i] != '0'){
    fa.push_back(num[i]);
    }
    }
    while(k > 0 && fa.size() > 0){
    fa.pop_back();
    k--;
    }
    if(fa.size() == 0){
    return "0";
    }
    else{
    return fa;
    }
    }
    };

  • @sailikpandey
    @sailikpandey 4 місяці тому

    Great Explanation Sir

  • @achrajpachauri3494
    @achrajpachauri3494 4 місяці тому

    Best Explaination !!!

  • @user-ub2is4rs4x
    @user-ub2is4rs4x 4 місяці тому +1

    Eid Mubarak bro. Aaj bhi video daaldiya 🥺

  • @prathamcreator1043
    @prathamcreator1043 4 місяці тому

    great solution bhaiya

  • @sonalkolhe4537
    @sonalkolhe4537 4 місяці тому

    Best Explanation🔥🔥🔥

  • @AmanKumar-qz4jz
    @AmanKumar-qz4jz 4 місяці тому

    bhaiya apne aapna intution itna acha kaise bana rakha h

  • @8daudio672
    @8daudio672 4 місяці тому

    ❤🪄ur magesian sir🎉

  • @jashanjotbedi1796
    @jashanjotbedi1796 4 місяці тому

    Please make video on 877 stone game question from leetcode .

  • @vm0305
    @vm0305 4 місяці тому +1

    I am not sure about my approach, but tried using sliding window of k size here, like for input num = "1432219", k = 3, we have windows 143, 432, 332, 221, and 219. Out of these, max one is 432. So, its removal gives 1219. When I implemented it, it gave TLE at last testcase 😅

    • @SumitKumar-du6vf
      @SumitKumar-du6vf 4 місяці тому

      yeah me too trying to do this but unable to implement it. Can you share your code here

    • @dss963
      @dss963 4 місяці тому

      That is not always gonna give you correct answer

  • @bhuppidhamii
    @bhuppidhamii 4 місяці тому +1

    Eid Mubarak

  • @coderletscode
    @coderletscode 4 місяці тому

    Eid Mubarak❤

  • @CodeMode9313
    @CodeMode9313 4 місяці тому

    Mast paaaji ....Eid mubarrak saar

  • @atanubasak7244
    @atanubasak7244 4 місяці тому

    I see future Coding Carryminati in your video

  • @bhuppidhamii
    @bhuppidhamii 4 місяці тому +1

    aaj pahli baar school m padha hua kaam aya 😅😅

  • @8daudio672
    @8daudio672 4 місяці тому

    Happy Eid sir❤

  • @factinsaan4333
    @factinsaan4333 4 місяці тому

    class Solution {
    public:
    string removeLeadingZeros(string &str) {
    size_t pos = str.find_first_not_of('0');
    if (pos !=string::npos) {
    return str.substr(pos);
    }
    return "0";
    }
    string removeKdigits(string num, int k) {

    if(k==num.length())
    return "0";
    string st="";
    int i=0,n=num.length();
    while(i

  • @aizad786iqbal
    @aizad786iqbal 4 місяці тому

    amazing explanation thank you
    I tried to solve this earlier without watching any videos... I was trying to remove consecutive numbers only, when my code started failing earlier then I realize it was wrong
    one doubt, when k>0 , e.g. 123678 after traversal we are removing from the back and not considering the place value here
    I can see from example those are the largest numbers but earlier place value was more important hence confused, so please explain

    • @codestorywithMIK
      @codestorywithMIK  4 місяці тому +1

      When a number is already in ascending order then removing from front will be better because we already have lower numbers in most significant places and don’t want to get rid of them.
      For example : “1234” , K = 2
      If you remove from front - “34”
      If you remove from back - “12”
      Obviously second one is smaller.

  • @JatinGupta-ze6nc
    @JatinGupta-ze6nc 4 місяці тому

    Bhai leetcode 53 kadane algorithm p ek video dalo please begineer se advance tk

  • @xyzhwhs
    @xyzhwhs 4 місяці тому

    Used dynamic programming , 23/43 test cases passed

  • @kunalpatil.24
    @kunalpatil.24 4 місяці тому +2

    Eid Mubarak!!!

  • @JagannathDebGunin
    @JagannathDebGunin 4 місяці тому

    Eid Mubarak dada❤

  • @VM-ek7td
    @VM-ek7td Місяць тому +1

    😊😊

  • @virendratambavekar61
    @virendratambavekar61 4 місяці тому

    Bhaiya Leetcode Q. No. 25 (Remove Nodes in K Group ) ka easy approach bato na

  • @user-ov5ds4rp9x
    @user-ov5ds4rp9x 4 місяці тому

    Love u bro, happy ugadi

  • @DeveloperRB
    @DeveloperRB 4 місяці тому

    understood

  • @pradeepranjan8226
    @pradeepranjan8226 4 місяці тому

    i submitted wrongly 6 times, coz of those shitty corner cases.
    But how do we know in real interview that these many corner cases are actually exist in the problem??
    Finding all corner cases are not easy sometime, thats what i feel.

  • @shreyrawat7108
    @shreyrawat7108 4 місяці тому

    Respect

  • @anandoganiya9070
    @anandoganiya9070 4 місяці тому

    Bro maximum wins from two segment ye wala question karo please

  • @xyzhwhs
    @xyzhwhs 4 місяці тому

    Dynamic programming is more intutive

  • @31parvjain32
    @31parvjain32 4 місяці тому

    Provide these slides link well It will be really helpful

    • @codestorywithMIK
      @codestorywithMIK  4 місяці тому

      Sure thing.
      I am a little occupied now, I will share the slide link tonight for sure ❤️❤️

  • @aa_maruf
    @aa_maruf 4 місяці тому

    ❤❤

  • @Ramgangakumar
    @Ramgangakumar 2 місяці тому

    aapka video kaafi long hota h thoda short banao sir...

  • @abcd76820
    @abcd76820 4 місяці тому

    mzaa aaya ❤

  • @solosanskar490
    @solosanskar490 4 місяці тому

    Stone Game 7 pe ek video bna do sir please

  • @gyandyan
    @gyandyan 4 місяці тому

    bhai yaar apan ko string de rki h like-"1432219" toh sabse chota Number jo ban sakta h vo toh ---"1122" here i remove 4,3,9... why this was not a answer ?? please tell me

  • @karnikasingh9140
    @karnikasingh9140 4 місяці тому

    💯💯💯💯💯💯

  • @chitranshjain9714
    @chitranshjain9714 4 місяці тому

    Please complete dp concept series

  • @bobybest1159
    @bobybest1159 4 місяці тому

    Leetcode 853

  • @vidishajahanvi4948
    @vidishajahanvi4948 4 місяці тому

    please solve in java also

    • @codestorywithMIK
      @codestorywithMIK  4 місяці тому

      I will definitely try to cover java coding in future videos. As of now, I put C++ as well as JAVA code in the github link in the description 😇🙏

  • @ayushsrivastava2829
    @ayushsrivastava2829 4 місяці тому

    full dsa laooo

  • @dhairyachauhan6622
    @dhairyachauhan6622 4 місяці тому +1

    i did on my own, can't believe i figured out the stack part (❁´◡`❁) but got an mle
    later on reading out the discussion section saw a person with the same problem,
    realised
    str = a + str is o(n)
    then used
    str.push_back(a);
    and revered it.
    class Solution {
    public:
    string removeKdigits(string num, int k) {
    stackst;
    for(auto &digit:num){
    while(k > 0 && !st.empty() && st.top() > digit){
    st.pop();
    k--;
    }
    if(st.empty() && digit == '0'){
    continue;
    }
    st.push(digit);
    }
    while(!st.empty() && k>0){
    st.pop();
    k--;
    }
    string ans;
    while(!st.empty()){
    char val = st.top();
    st.pop();
    ans.push_back(val);
    }
    reverse(ans.begin(),ans.end());
    return ans == ""?"0":ans;
    }
    };

  • @AmruthavarshiniMavuri
    @AmruthavarshiniMavuri 4 місяці тому

    Bhaiyya can you explain in English in your videos

  • @manishkumarnirmalkar5633
    @manishkumarnirmalkar5633 4 місяці тому

    Bhaiya but sabse chota to 1123 ho ga na

    • @codestorywithMIK
      @codestorywithMIK  4 місяці тому

      You can’t rearrange the digits in the string

  • @SHIVAMOJHA21
    @SHIVAMOJHA21 4 місяці тому +1

    aise teacher ke itne kam subscribers?😕

  • @souravjoshi2293
    @souravjoshi2293 4 місяці тому

    thumbnail 😂🔥🔥

  • @user-me6iq2iq4t
    @user-me6iq2iq4t 4 місяці тому

    Bro your leetcode id