Rotate Array

Given an array nums and an integer k, rotate the array to the right by k steps.

Input Format

nums = array of integers, k = rotation steps

Output Format

rotated array

Constraints

  • 1 <= nums.length <= 10^5; -10^9 <= nums[i] <= 10^9; 0 <= k <= 10^9

Examples

Example 1:

Input:

nums = [1,2,3,4,5,6,7]
k = 3

Output:

[5,6,7,1,2,3,4]

Explanation:

Last 3 elements come to front.

Loading...
Rotate Array - Arrays DSA Problem