• + 0 comments

    JS/Javascript solutiuon:-

    function circularArrayRotation(a, k, queries) {
      const actualRotation = k % a.length;
      let newArr = a;
      if (actualRotation) {
        const rightPart = a.splice(a.length - actualRotation);
        newArr = [...rightPart, ...a];
      }
      return queries.map((query) => newArr[query]);
    }