List Rotation (Problem 16) - InfyTQ Solution in Python

List Rotation (Problem 16)

InfyTQ Solution in Python

Photo by Logan Kirschner from Pexels

PROBLEM STATEMENT

Write a Python function to rotate the list of elements by N positions. The function should return the rotated list.


Sample Input Expected Output
Input list: [1, 2, 3, 4, 5, 6] Number of positions to be rotated = 2 [5, 6, 1, 2, 3, 4]
Input list: [1, 2, 3, 4, 5, 6] Number of positions to be rotated = 4 [3,4,5, 6, 1, 2]

Note : Assume that number of positions to be rotated is always a value >= 0 and <= length of the input list.


SOLUTION
SHARE If you find this useful, please share with your friends and Community.
CODE TOGETHER..GROW TOGETHER.
Newer Posts Newer Posts Older Posts Older Posts

More posts

Comments

Post a Comment

Sponsored Content