#47 - Rotate Array by one position
You are given an array of integers and a direction (left or right). Your task is to implement a function to rotate the array by one position in the specified direction.
Example 1
Input
nums = [1, 2, 3, 4, 5]
direction = "left"Output
[2, 3, 4, 5, 1]Example 2
Input
nums = [1, 2, 3, 4, 5]
direction = "right"Output
[5, 1, 2, 3, 4]Last updated