We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
functionquickSort(arr:number[]):number[]{// for resusableconstsplit=(arr:number[]):[number[],number[],number,number[]]=>{letpivot=arr[0]letlh=[]letrh=[]for(letiinarr){if(arr[i]<pivot)lh.push(arr[i])if(arr[i]>pivot)rh.push(arr[i])}return[[...lh,pivot,...rh],lh,pivot,rh]}returnsplit(arr)[0]}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Quicksort 1 - Partition
You are viewing a single comment's thread. Return to all comments →
My answer in Typescript, func to reusable