LEETCODE 88 (JAVASCRIPT) | MERGE SORTED ARRAY

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

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

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

    BEST EXPLANATION TILL DATE!! THE WAY YOU EXPLAINED THE CONCEPT IT WAS SO NICE THAT I DID IT WITHOUT THE HELP OF ANY CODE SOLUTION JUST BASED ON THE LOGIC THAT YOU GAVE IN THE VIDEO..
    THANKS MANN!!!!

  • @enriquegrageda
    @enriquegrageda 9 หลายเดือนก่อน +1

    Had to watch it 3 times, it makes sense,
    thanks for making this video!

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

    I was struggling with understanding this problem and the solution for few days,thanks to that video i finally get it. Amazing!

  • @UmaSahni.
    @UmaSahni. ปีที่แล้ว

    blessed with your explanation !!

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

    Hey, Andy Thank you for the explanation. I will have a question in a case where nums1 =[5,6,0,0,0] m=2 nums2=[1,2,3] n=3 . For this case "first" going "-1". What am I missing here?

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

    very bussin explanation

  • @jillysong4751
    @jillysong4751 9 หลายเดือนก่อน

    What if all values in first array are greater than those in second array and the first pointer goes out of range first?

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

    Can anyone tell me which 'drawing' software is he using plz?

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

    Are you still doing tutorials? I have no problem paying you for more videos…Google sent me a list of algorithms and I am in love with the way you do your conceptual work

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

      Thanks for the kind words :). I’m currently a SWE at Atlassian so taking some time off from making vids. Def recommend studying the ones that are up as they cover 90 percent of the patterns you’ll see everywhere. Best of luck on the journey!

  • @JorgeDiaz-i4m
    @JorgeDiaz-i4m ปีที่แล้ว

    Why not write decrement i once outside of the if statement?

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

    I've done this one like:
    const merge = function(nums1, m, nums2, n) {
    nums1.length = m;
    nums1.push(...nums2);
    nums1.sort()
    };
    It was accepted by leetcode. What do you think about this solution?

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

      Go to Solutions, and watch the video in the beginning. They will explain why .sort is less optimal

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

      Also i think this solution use too many built in functions from js

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

      Yes you solved 😂, but the purpose of leetcode are to train your algorithm and data structure, better to do manually 😅

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

    Thank you man

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

    bless

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

    Is this really an easy one to solve? It is in the easy category, but I do not understand it.

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

      lol yeah I've been grinding leetcode all day and I got to this one on the easy section and it broke my brain. time for sleep.

  • @Michael-kp4bd
    @Michael-kp4bd 2 ปีที่แล้ว

    I think the time complexity of O(m+n) you calculated is NOT reducible to O(n).
    They’re independent arrays:
    If m is huge, it’s significant. If n is huge, it’s significant.
    Worst case, you walk through each element of m and n. I think that happens any time n[0] < m[0] because you don’t break out of the “while” condition until n[0] gets sorted into m[0]. In other words, you have to update “i” exactly m+n times.
    I think interviewers like when you recognize these things and don’t drop constants just because you’re used to, say, O(2n) reducing to O(n).
    So I think true time complexity is O(m+n). Definitely feel free to correct me if I’m wrong!

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

    i think this solution is only valid, for some reason, in JavaScript. Other languages like Go will give me index out of range if i have inputs like this: nums1 = [2,0], m = 1, nums2[1], n = 1
    in Go i would have to check if first >= 0 before assigning or comparing .Javascript accepts nums1[-1] returns undefined and, by luck maybe, goes to the else clause.