← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Given an integer array nums, rotate the array to the right by k steps.
Requirement: Solve in-place with O(1) extra space.
Key Insight: The O(1) space solution uses the reversal algorithm: