...

/

Rotate an Array by N Elements

Rotate an Array by N Elements

Given an integer array, rotate it 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.

Access this course and 1400+ top-rated courses and projects.