You are viewing a single comment's thread. Return to all comments →
JS Math solution
function processData(input) { var lines = input.split('\n'); var arr = lines[1].split(' '), rot = lines[0].split(' ')[1], n = arr.length; for (var i = 2; i < lines.length; i++) { var m = lines[i], oldM = (n + (m - (rot % n))) % n console.log(arr[oldM]); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Circular Array Rotation
You are viewing a single comment's thread. Return to all comments →
JS Math solution