• + 0 comments

    JAVASCRIPT BIG O(N) SOLUTION:

    for(let i=0;i<k;i++) {
    			// Remove the last elment and add into the first position and moves remaining element to the right
            a.unshift(a.pop());
        }
        let finalArr = queries.map((query) => a[query]);
        return finalArr;