Write a function to manipulate an array while maintaining constant space complexity.
For this task, rotate the input array to the right by k positions in place and return the same array. The relative order must be preserved after rotation, and the algorithm may use only O(1) additional space.
Function: manipulate_array(nums, k)
The input is a non-empty list of integers and a non-negative integer k. Modify nums directly and return it.
def manipulate_array(nums, k):