Rotate an Array by N Elements


We’re given an array of integers, nums. Rotate the array by n elements, where n is an integer:

  • For positive values of n, perform a right rotation.
  • For negative values of n, perform a left rotation.

Make sure we make changes to the original array.

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.