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.
functioninsertionSort2(n:number,arr:number[]):void{/** * again, simple as question request * loop [i] from 1, call [insertionSort1] by that sub-array * print each loop * * note: [insertionSort1] is answer of previous question * (return arr instead of print) */for(leti=1;i<arr.length;i++){arr=[...insertionSort1(arr.slice(0,i+1)),...arr.slice(i+1)]console.log(arr.join(' '))}}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 2
You are viewing a single comment's thread. Return to all comments →
My answer in Typescript, simple