📌  相关文章
📜  javascript代码示例中的循环数组旋转hackerrank解决方案

📅  最后修改于: 2022-03-11 15:01:49.731000             🧑  作者: Mango

代码示例1
// circular array rotation hackerrank solution in javascript
function circularArrayRotation(a, k, queries) {
  // Write your code here
  for(let i = 0; i < k; i++) {
    a.unshift(a.pop());
  }
  let arr = [];
  for(let j = 0; j < queries.length; j++) {
    arr.push(a[queries[j]]);
  }
  return arr;
}