Last week, a CSoahelp client took a TikTok VO interview, and the problem was both classic and flexible:
“Given an integer array
nums
, rotate the array to the right byk
steps, wherek
is non-negative.”
The interviewer even gave an example:
Input: nums = [1,2,3,4,5,6,7], k = 3
Output: [5,6,7,1,2,3,4]
Below is a concise walkthrough that keeps as much of the essential content as possible.
The simplest and most common in-place solution (using only O(1) extra space) is:
- First, reverse the entire array.
- Then, reverse the first
k
elements. - Finally, reverse the remaining
n−k
elements.
By doing this, the last k
numbers naturally move to the front and end up in the correct order—no auxiliary array needed. In code, you just start with k = k % n
, and in your reverse function, use a two-pointer swap (swap(nums[i], nums[j])
while i < j
).
The interviewer asked pretty comprehensive follow-up questions, so keep that in mind.
“Shi,” our instructor, was very happy to hear that after the interview, HR reached out almost immediately to schedule the next round.
For more real interview questions, follow Shi’s Xiaohongshu account:
https://www.xiaohongshu.com/user/profile/62b27695000000001902bd36
You can also add Shi’s personal WeChat for consultation.

If you need more interview support or interview proxy practice, feel free to contact us. We offer comprehensive interview support services to help you successfully land a job at your dream company.