nums in non-decreasing order.\n- Initialize minDifference to a large value.\n- Iterate over the array with a window of size k:\n - For each window, calculate the difference between the last and first elements in the window.\n - Update minDifference if the current difference is smaller.\n- Return minDifference as the result.