Rotate an Array by N Elements

Statement

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 80+ hands-on prep courses.