Rotate Array

Medium
ArrayTwo PointersMathMicrosoftAmazon
Given an array and a nonnegative integer k, rotate the array to the right by k positions and print the result. Input format: - First line: n k - Second line: n integers

Constraints

1 <= n <= 10^5
0 <= k <= 10^9
-10^9 <= nums[i] <= 10^9

Sample tests

Sample 1

Sample 2

Sign in to submit