Rotate Array — C# Coding Problem
Difficulty: medium | Category: array
Problem Description
Given an integer array `nums`, rotate the array to the right by `k` steps, where `k` is non-negative. **In-place O(1) extra space trick:** Reverse the whole array, then reverse the first `k` elements, then reverse the rest. **Follow-up:** Try to come up with as many solutions as you can.
Examples
Example 1
Input: nums = [1,2,3,4,5,6,7], k = 3
Output: [5,6,7,1,2,3,4]
Example 2
Input: nums = [-1,-100,3,99], k = 2
Output: [3,99,-1,-100]