LEETCODE 912 (JAVASCRIPT) | SORT AN ARRAY (QUICK SORT)

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

КОМЕНТАРІ • 11

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

    Best vid I found today for understanding quick sort. Thank you!

  • @SwiddyDiddy
    @SwiddyDiddy 2 роки тому +1

    Thanks. Most other videos I found stored the left and right arrays in their own separate arrays, completely nullifying the point of more efficient space complexity over merge sort. There's no reason to use this otherwise, as the in-place sorting is the whole point. Other than it being a tail-recursive function I guess.

  • @yadwindersingh9722
    @yadwindersingh9722 2 роки тому +2

    Hi sir, These leetcode videos are amazing, please make more videos like this, Thanks

  • @henryleestudio
    @henryleestudio 2 роки тому +1

    What if left is not greater than right in the beginning?

  • @sinxenon3181
    @sinxenon3181 Рік тому

    Thank you so much!

  • @michaelchan6144
    @michaelchan6144 3 роки тому

    Great vid!

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

    My answer:
    var sortArray = function(nums) {

    let sortedArray = nums;
    sortedArray.sort(function(a,b){return a-b});
    return sortedArray;

    };

    • @DeadlyTrust
      @DeadlyTrust 2 роки тому +1

      I think the point of the exercise was to implement the sort mechanism from scratch. Of course there's a built in sort function thats based on the quick-sort algorithm. If it was that easy, then this problem will be tagged easy.

    • @jokwonpope1561
      @jokwonpope1561 2 роки тому +1

      in interviews you will not be able to use sort()

    • @bhavyakhunt
      @bhavyakhunt 2 роки тому +1

      @@jokwonpope1561 thanks for that, I had just started JS when I posted that comment

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

    Great!😅