• + 1 comment

    More algorithmic? - I don't see any reason to mutate the arrays at all, if all you need is the correct indexes from the rotated input. This just plucks the relevant items from the (rotated) indexes in the query:

    function circularArrayRotation(a, k, queries) {
        let offset = a.length - (k % a.length);
        return queries.map( e => a[(e+offset)%a.length]);
    }