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.
functionjimOrders(orders){// Write your code hereletans=0letarr=[]for(leti=0;i<orders.length;i++){letx=orders[i][0]+orders[i][1]arr.push([x,i+1])}for(leti=0;i<arr.length-1;i++){for(letj=0;j<arr.length-i-1;j++){if(arr[j][0]>arr[j+1][0]){[[arr[j],arr[j+1]]]=[[arr[j+1],arr[j]]]}}}for(leta=0;a<arr.length;a++){arr[a]=arr[a][1]}returnarr}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Jim and the Orders
You are viewing a single comment's thread. Return to all comments →
Simple JS Solution