You are viewing a single comment's thread. Return to all comments →
found out what the problem was, new JS code:
function circularArrayRotation(a, k, queries) { var rarr = []; var aind = []; var res = []; for (var i = 0; i < a.length; i++){ if ((i + k) < a.length) { aind[i] = i + k; } else { aind[i] = (i + k) % a.length; } } for (var j = 0; j < a.length; j++) { rarr[aind[j]] = a[j]; } for (var k = 0; k < queries.length; k++){ res[k] = rarr[queries[k]]; } return (res); }
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 →
found out what the problem was, new JS code: