A TCS MasterCraft data-processing component needs to shift an in-memory sequence by a requested number of positions. Given an array of integers, a rotation count k, and a direction, rotate the array in place and return the resulting array.
A left rotation moves the first element to the end. A right rotation moves the last element to the beginning. Rotations must support values of k larger than the array length, and the original array must be modified without creating another array proportional to its size.
Implement rotate_array(nums, k, direction).
nums is a non-empty list of integers.k is a non-negative integer.direction is either `def rotate_array(nums, k, direction):