• + 0 comments

    Here is my Python solution! We insert the last item at the front and then remove the last item however many times we need to, and then return where each value that we need to return.

    def circularArrayRotation(a, k, queries):
        for i in range(k):
            a.insert(0, a[-1])
            a.pop(-1)
        return [a[i] for i in queries]