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.
functionrunningTime(arr){// Write your code hereconstn=arr.lengthleti=0letshift=0while(i<n-1){lettemp=arr[i+1]if(temp<arr[i]){letj=0;while(arr[j]<=temp)j++for(letk=i+1;k>j;k--){arr[k]=arr[k-1]shift++}arr[j]=temp}i++}returnshift;}
Cookie support is required to access HackerRank
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 solution