You are viewing a single comment's thread. Return to all comments →
javascript
function runningTime(arr) { // Write your code here let shiftcount = 0; for (let i = 1; i < arr.length; i++) { for (let j = i-1; j>=0; j--) { if (arr[j] > arr[j+1]) { [arr[j], arr[j+1]] = [arr[j+1], arr[j]] shiftcount++ // console.log(shiftcount) } else{ break } // console.log(...arr) } } return shiftcount }
Seems like cookies are disabled on this browser, please enable them to open this website
Running Time of Algorithms
You are viewing a single comment's thread. Return to all comments →
javascript