Merge Two Sorted Lists || Leetcode 21 || 2 Variant Questions Meta Actually Asks

Поділитися
Вставка
  • Опубліковано 4 лют 2025

КОМЕНТАРІ • 20

  • @BananaButcher
    @BananaButcher 7 днів тому

    clean to the point nice ! glad i found this channel

  • @hsinyang1796
    @hsinyang1796 8 днів тому

    amazing work thank you!

    • @CodingWithMinmer
      @CodingWithMinmer  8 днів тому

      I really appreciate that, thank you and good luck on your interviews. You got this!

  • @jamesperaltaSWE
    @jamesperaltaSWE 11 днів тому

    Nice work!!

    • @CodingWithMinmer
      @CodingWithMinmer  11 днів тому

      Ty :)

    • @sosanyaayonitemi2885
      @sosanyaayonitemi2885 7 днів тому

      @@CodingWithMinmer nice work. Turns out meta's now asking merge K sorted arrays also

    • @CodingWithMinmer
      @CodingWithMinmer  7 днів тому

      @@sosanyaayonitemi2885 100%. I plan on covering that when I get to LC#23 since it's slightly more related.

    • @sosanyaayonitemi2885
      @sosanyaayonitemi2885 7 днів тому

      @ nice, that’s awesome

    • @sosanyaayonitemi2885
      @sosanyaayonitemi2885 7 днів тому

      @@jamesperaltaSWE basically as much as one can under the leetcode top meta 100 sorted by last 3-6 months

  • @tanayjoshi1322
    @tanayjoshi1322 11 днів тому

    Hey! I had my followup coding round yesterday for E3 role. Thanks for all your videos they have been super helpful. Can you help me with a question I had? I am kinda worried maybe I am overthinking?
    I was coding up brute force and I got stuck. Instead of completing the brute, I switched to the optimal approach. Explained my approach, coded and dry ran my code on two examples. Answered follow ups correctly and gave correct TC and SC
    Does this hurt my chance of leaving brute midway and switching to optimal in between? My explanation was okayish for brute as I was explaining and coding. I didnt know how to proceed further thats why I had to switch to optimal.

    • @CodingWithMinmer
      @CodingWithMinmer  10 днів тому

      Thank you!
      Which Leetcode problem was it?
      That sounds tricky since ideally you'd explain the brute force solution just to point out its downfalls, to then transition into the optimal approach.
      As long as you didn't make it seem like you didn't know the actual brute force code, you'll be okay. Being an E3, they'll have more leniency, but of course they'll evaluate all of your Leetcode rounds as a whole.
      Good luck and congratulations for making it this far. The hiring committee meet every Tuesday and Thursday, so there's nothing left to do but play the waiting game. Let me know how it goes!

    • @tanayjoshi1322
      @tanayjoshi1322 10 днів тому

      @
      It was top K frequent elements.
      So at one point I was lost and didnt know what I was doing. I couldnt explain brute completely because I was stuck and was somehow trying to find a way thru. I was sorting dictionary by frequency (I did mention TC would be NlogN) and didnt know what to do further. I was trying to find top k elements in decreasing order of freq. since dictionary will give me a key: freq mapping. I wanted to sort by freq which I did but didnt know how to proceed ahead. I wanted to loop over freq and get corresponding elements. I was stuck
      Then I shifted gears and said “I have another idea in mind, instead of sorting dictionary, we could rather use a bucket sort approach.” “Works very well when something is needed to be sorted by frequency. Do you think we could go along with that?” Something along these lines.
      And then I explained him the optimal i.e, how bucket sort will solve this problem. Asked if he followed the approach. Mentioned that frequency of the number will act as the index of the bucket. drew buckets and all, coded, DRY ran the code and answered followups, gave correct TC and SC

    • @CodingWithMinmer
      @CodingWithMinmer  10 днів тому +1

      @@tanayjoshi1322 Looks great to me. I see what you were trying to do.
      As a bonus, did you call out the weaknesses of bucket sort? e.g. what if there are very, very large numbers in the list (that would consume more storage space)?
      Did you also talk about other solutions like quickselect, heaps, etc? I'm just trying to gather more context.
      Sounds like you got a decent chance though.

    • @tanayjoshi1322
      @tanayjoshi1322 10 днів тому

      @@CodingWithMinmer I did mention that the max number of buckets will be when the same number takes the entire array. That is an element will appear len(arr) times. Even then, bucket sort will create N buckets. And the last bucket will be filled with the number. So worst case space will be O(MAX FREQ=N).
      I did not talk about quick select or heaps.
      I also asked a clarification. Whether he wanted me to prioritise any number like what if multiple numbers appear the same no. of times. Did he want them to appear in asc or desc order in the output? He said no. Any order is fine. But still I went ahead and said we would just rather loop over from the end of the bucket. He pointed out that was wrong. I said “Oh yea. The order would actually depend on the frequency and where in the list the numbers appear.” He asked so how would you fix this. I said “Each bucket could be a heap on it own. And we will just push/pop from the heap instead of having to sort every time. And each push pop will have a logN time complexity.” He seemed happy with that. I guess I basically gave him a scope to ask a followup question here preemptively.
      In another question. I wrote brute and optimal both. DRY ran on 4-5 cases. He seemed satisifed. It was Valley element in an array (valley element is an element which is less than or equal to its immediate neighbors). Clarified about the boundaries. Can I assume them to be INF? He said yea go ahead. Asked about input size. Asked whether a valley element will always be present in the array or not. He said “You tell me”. I said “Yes. It will ALWAYS exist. Because the condition is

    • @tanayjoshi1322
      @tanayjoshi1322 10 днів тому

      Really looking forward to your advice/thoughts here 😭🙏