You are viewing a single comment's thread. Return to all comments →
Python index slicing makes this trivial :D
def array_left_rotation(a, n, k):
return a[k:] + a[:k]
That's the simplest solution in Python!
There will be an index error if k is larger than len(a)
Can be easily fixed with k%len(a) .