We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Circular Array Rotation
Circular Array Rotation
Sort by
recency
|
3074 Discussions
|
Please Login in order to post a comment
My solution
IndexError: list index out of range
Here is my c++ solution, you can watch the explanation here : https://youtu.be/MaT-4dnozJI
Solution 1 O(n + m) :
Solution 2 O(m) :
`
def reverse(a,l,r): i=l j=r while i
def circularArrayRotation(a, k, queries): k=k%len(a) reverse(a,0,len(a)-1) reverse(a,0,k-1) reverse(a,k,len(a)-1) l=[] for i in queries: l.append(a[i]) return l