nums
in non-decreasing order.k
is greater than 0, negate the number and decrement k
.k
is still greater than 0 after negating all negative numbers, check if k
is odd.k
is odd, negate the smallest absolute value in the array (which will be the first element after sorting).