Asteroid Collision | Intuition | Dry Run | Leetcode-735 | Uber | Lyft | Explanation ➕ Live Coding

Sdílet
Vložit
  • čas přidán 24. 07. 2024
  • Hi everyone, this is the 12th video of our Stack playlist.
    In this video we will try to solve a very good and famous stack problem "Asteroid Collision". (Leetcode-735)
    We will write very easy and clean code with intuition building and understanding each line of code.
    We will do live coding after explanation and see if we are able to pass all the test cases.
    Problem Name : Asteroid Collision
    Company Tags : Uber, Lyft
    My solutions on Github : github.com/MAZHARMIK/Intervie...
    Leetcode Link : leetcode.com/problems/asteroi...
    My GitHub Repo for interview preparation : github.com/MAZHARMIK/Intervie...
    Subscribe to my channel : / @codestorywithmik
    Instagram : / codestorywithmik
    Facebook : / 100090524295846
    Twitter : / cswithmik
    ╔═╦╗╔╦╗╔═╦═╦╦╦╦╗╔═╗
    ║╚╣║║║╚╣╚╣╔╣╔╣║╚╣═╣
    ╠╗║╚╝║║╠╗║╚╣║║║║║═╣
    ╚═╩══╩═╩═╩═╩╝╚╩═╩═╝
    #coding #helpajobseeker #easyrecipes #leetcode #leetcodequestionandanswers #leetcodesolution #leetcodedailychallenge #leetcodequestions #leetcodechallenge #hindi #india #hindiexplanation #hindiexplained #easyexplaination #interview #interviewtips
    #interviewpreparation #interview_ds_algo #hinglish

Komentáře • 79

  • @VedaVyasaa
    @VedaVyasaa Před rokem +19

    you're really doing a great job man. Helping out a lot of students. Hats off and stay consistent. Your channel will surely be a success. 💌💌

  • @amanpratapsingh3256
    @amanpratapsingh3256 Před 11 dny +2

    After striver i find you who visualise the algorithm in such detail....hats off to you ....for putting such long explanation videos....keep up the good work man!!

  • @prathamtetgure2963
    @prathamtetgure2963 Před rokem +7

    Ur Calm Voice Explaination is THE BEST

  • @aws_handles
    @aws_handles Před 6 měsíci +1

    Dope explanation . Most underrated channel ❤

  • @rahulmandal3018
    @rahulmandal3018 Před 6 měsíci +3

    Such an underrated channel man!.... Never seen this type of explanation. Loved your content bhai♥

    • @codestorywithMIK
      @codestorywithMIK  Před 6 měsíci

      It means a lot Rahul
      Thank you for your kind words ❤️❤️🙏🙏

  • @souravjoshi2293
    @souravjoshi2293 Před rokem +1

    Crystal clear like always.

  • @itsaryanb9316
    @itsaryanb9316 Před 4 měsíci +1

    Perfectly Explained, Thank You !!

  • @user-vd2jc7lm3h
    @user-vd2jc7lm3h Před rokem +2

    nice explanation

  • @AnjuGupta-sz1uk
    @AnjuGupta-sz1uk Před 6 měsíci +2

    learnt best way of using vector as stack

  • @wearevacationuncoverers

    Made it too easy to understand. Thanks a lot

  • @DurgaShiva7574
    @DurgaShiva7574 Před rokem +1

    the way u teach is mind blowing, those who run paid courses are nothing in front of explanation u give, hats off 2 u

  • @mohd.tabishkhan4868
    @mohd.tabishkhan4868 Před 6 měsíci +1

    Epic solution

  • @anuppatankar4294
    @anuppatankar4294 Před rokem +2

    Great Video 😍

  • @BiswajitDas-lk7pp
    @BiswajitDas-lk7pp Před 5 měsíci

    Amazing Explainaton 💯💯 ThankYou

  • @kartikrameshchavan6662
    @kartikrameshchavan6662 Před rokem +2

    Op 👍

  • @priyanshugoutam1223
    @priyanshugoutam1223 Před 9 měsíci +1

    did it on my own but watched the video till the end and improved my code thank you , also I have completed your stacks playlist now

    • @codestorywithMIK
      @codestorywithMIK  Před 9 měsíci

      So glad to know. Thank you for watching 😇🙏
      Today’s POTD now being uploaded

  • @venomdhruv2220
    @venomdhruv2220 Před 8 měsíci +5

    what if the asteroids array also contains 0 because on coding ninjas the same question is there but it also has 0 as input in that case the code is giving error for the testcases

    • @HammyHues
      @HammyHues Před 11 dny +1

      As per the question, 0 is not valid. As the values in array represent Size, So size can never be zero. ( sign represent directions , '+' -> right , '-'

  • @anubhavdeepankar6681
    @anubhavdeepankar6681 Před měsícem +2

    this solution is the best

  • @dayashankarlakhotia4943
    @dayashankarlakhotia4943 Před rokem +1

    Intuition and explanation is superb 👌. your channel becomes most popular in dsa

  • @AyushRaj-we2og
    @AyushRaj-we2og Před rokem +1

    Understood!😇

  • @vikrant2766
    @vikrant2766 Před rokem +1

    Short , sweet and to the point explaination no cap❤

  • @kishan.17
    @kishan.17 Před rokem +1

    thank soo much bro explaination quality is next level ,super explaination🥰

  • @user-kg4pl6im9g
    @user-kg4pl6im9g Před rokem +1

    may god bless with lots of health and wealth bro!! you're awesome af

    • @codestorywithMIK
      @codestorywithMIK  Před rokem

      Thank you so much
      It means a lot ❤️❤️
      I wish the same for you all 😇

  • @shivansh2870
    @shivansh2870 Před rokem +1

    jai ho mik baba ki

  • @satyamgupta4808
    @satyamgupta4808 Před 9 měsíci

    nice bro

  • @dprsd042
    @dprsd042 Před 11 měsíci +1

    Amazing explanation about the way you think of the approach to solve the question 💯🔥

  • @perspectives1827
    @perspectives1827 Před 7 měsíci +1

    Thankyou so much for explaining every why clearly

  • @pryansh_
    @pryansh_ Před 9 měsíci +1

    it was really helpful.

  • @amitkumarchoudhary9008
    @amitkumarchoudhary9008 Před rokem +2

    Bhaiya u r awesome !!

  • @ayanahmed2221
    @ayanahmed2221 Před rokem +1

    Best explaination 👏

  • @codeandtalk6
    @codeandtalk6 Před rokem +1

    Solved it on my own ❤❤❤

    • @codestorywithMIK
      @codestorywithMIK  Před rokem +6

      I am the happiest when I hear this in my comment section.
      Together we all are growing 💪💪💪

  • @good114
    @good114 Před 10 měsíci +1

  • @DurgaShiva7574
    @DurgaShiva7574 Před rokem

    please if possible start a playlist on LLD for experienced folks.

  • @prem_kumar
    @prem_kumar Před 11 dny +8

    who is here after robot collision video?

  • @VA04
    @VA04 Před 5 měsíci

    i say only one thing thanks man.

  • @asmitsrivastava924
    @asmitsrivastava924 Před 8 měsíci +2

    your videos are very helpful

  • @anshumaan1024
    @anshumaan1024 Před 3 měsíci +1

    TC using vector, O(N^2) nhi hoga ? 🤔🤔
    kyoki pop_back() krne ke baad vector resize bhi toh hoga, which will take O(N) operation

  • @shambhavisoni2297
    @shambhavisoni2297 Před rokem +2

    in collision case,
    instead of taking sum can't we just check if top is greater than arr[i] we don't need to do anything.
    if top

    • @shambhavisoni2297
      @shambhavisoni2297 Před rokem

      like this
      class Solution {
      public:
      vector asteroidCollision(vector& asteroids) {
      stack st;
      st.push(asteroids[0]);

      for(int i=1;i=0 && st.top()>=0) || (asteroids[i]

    • @ashishdhal4614
      @ashishdhal4614 Před rokem +1

      Yes we can do it in a 2n time if stack is monotonous keep appending if there is a change use a while loop to pop

    • @codestorywithMIK
      @codestorywithMIK  Před rokem +1

      Yesss

    • @shambhavisoni2297
      @shambhavisoni2297 Před rokem

      @@codestorywithMIK time complexity will still be same?

    • @AyushRaj-we2og
      @AyushRaj-we2og Před rokem

      I did the same way :)

  • @user-ub2is4rs4x
    @user-ub2is4rs4x Před 8 měsíci

    There is only one MIK and there will be only one. Never seen this teaching level before

  • @ultimatequora
    @ultimatequora Před rokem +1

    Kindly tell if love babbar sheet 450 is enough or if I should do more ,also suggest what more I should do .
    I am preparing for google summer intern 2023 program.

    • @codestorywithMIK
      @codestorywithMIK  Před rokem

      Hi,
      Actually i have never solved from any sheet.
      But if that list help you revise and has all tooic, then it should be good.

  • @dhairyachauhan6622
    @dhairyachauhan6622 Před rokem +1

    i solved this on my own but took abt 1hr 😞😞. I always take about 1hr -2hrs hence feel demotivated coz you only get 35-45 min in an interview. How do i overcome this.

    • @codestorywithMIK
      @codestorywithMIK  Před rokem +2

      Don't worry, initially it happens. But with more practice our speed will increase.
      Keep practicing.

  • @priyadarshanghoshhazra7648

    Can this be done without extra space?

    • @codestorywithMIK
      @codestorywithMIK  Před rokem +1

      It means we want to modify the input given.
      It can be done but it will be O(n^2) because you need to travel back to vector again and again in case collision happens. Also the size of vector will keep on changing as you delete elements

  • @Bibhukalyan_iitkgp_21
    @Bibhukalyan_iitkgp_21 Před rokem +1

    Sir Bitmask dp padha dijiye plzzzzzzzzzz

    • @codestorywithMIK
      @codestorywithMIK  Před rokem +1

      Definitely it will be covered in this - czcams.com/play/PLpIkg8OmuX-JhFpkhgrAwZRtukO0SkwAt.html

  • @floatingpoint7629
    @floatingpoint7629 Před rokem +1

    thanks for the explanation. here is my solution:
    /**
    * @param {number[]} asteroids
    * @return {number[]}
    */
    var asteroidCollision = function (asteroids) {
    // 5 ----> positive means right
    // negative means left 5----> positive positive does not collide
    // 0) {
    a = 0;
    break; // the asteriod on stack was bigger then the incoming one
    }
    else {
    st.pop();
    a = 0;
    break;
    }
    }
    if (a != 0) st.push(a);
    }
    return st;
    };

  • @Thriftinghai
    @Thriftinghai Před rokem

    My one stop solution to all problems - codestorywithMIK