FastPrepRotate Array Right
Problems/Rotate Array Right

Rotate Array Right

Omnissa logoOmnissa● MediumONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamples

Problem statement

You are given an integer array nums and an integer k. Rotate the array to the right by k steps and return the rotated array.

Function

rotateRight(nums: int[], k: int) → int[]

Examples

Example 1

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

Moving the last three values to the front gives [5,6,7,1,2,3,4].

Example 2

nums = [-1,-100,3,99]k = 2return = [3,99,-1,-100]

After two right rotations, 3 and 99 move to the front.

See Omnissa hiring insights
Saved
class Solution {
    public int[] rotateRight(int[] nums, int k) {
      // write your code here
    }
}
Checking account…