MERGE K SORTED LISTS | LEETCODE 23 | PYTHON OPTIMAL SOLUTIO

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

КОМЕНТАРІ •

  • @ahsanshafiqchaudhry
    @ahsanshafiqchaudhry 7 місяців тому +3

    Thanks! Great Explanation.
    Just one observation: Recursive calls always consume (stack) space, I think if you replace the merge(self, l1, l2) with iterative version, that would be actually constant space.

  • @jayeshbhoi6844
    @jayeshbhoi6844 2 роки тому +3

    Never seen such crisp and simple approach to solve this problem in any other channel. So addicted to problem solving method. Thanks

    • @crackfaang
      @crackfaang  2 роки тому

      Thanks for the kind words and welcome to the channel

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

    thanks for explaining the logic for the indices to skip, and explaining the code so well!! Appreciate it !

  • @ajvercueil8111
    @ajvercueil8111 7 місяців тому +1

    Thanks for another great explanation, you always make complex solutions and approaches so easy to understand.
    Quick heads up, the merge function you defined is recursive, so your space complexity is O(n + m) due to recursive stack frames.
    The first call to merge does not return until the ends of both l1 and l2 have been reached, so n+m stack frames consume O(n+m) space.
    To maintain O(1) space complexity, we should iteratively merge the linked lists.

  • @dnm9931
    @dnm9931 8 місяців тому

    Thanks a lot for a clear and concise optimal solution. I love how straight to the point you are!

  • @sharduldave8286
    @sharduldave8286 9 місяців тому

    Thank you for your video, it really helped me understand the problem and the solution for it

  • @sonicspider49
    @sonicspider49 3 місяці тому

    Nice video!

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

    Can this be solved using heaps? Is that the expected solution?

  • @YT.Nikolay
    @YT.Nikolay 2 роки тому

    It's probably was my first hard problem I managed to solve myself :) 🥳🥳🥳

    • @crackfaang
      @crackfaang  2 роки тому

      Amazing! Progress feels great doesn't it?

    • @YT.Nikolay
      @YT.Nikolay 2 роки тому

      @@crackfaang it does feel sooooo good! :)