Left Rotate
Problem to left rotate the list elements in k times. Left Rotate is to move the element in left to right.
Example-1:
Input : n = [ 1, 2, 3, 4, 5] , k = 1 Output : [2, 3, 4, 5, 1]
Example-2:
Input : n = [ 1, 2, 3, 4, 5] , k = 2 Output : [3, 4, 5, 1, 2]
Solution
n = [ 1, 2, 3, 4, 5] k = 1 a = n[k:] + n[:k] print(a)
Output
[2, 3, 4, 5, 1]