Very simple Java solution with comments
Complexity
Time complexity: O(nlogn)

Space complexity: O(1)
Code
# Complexity
- Time complexity: $$O(nlogn)$$ 
<!-- Add your time complexity here, e.g. $$O(n)$$ -->

- Space complexity: $$O(1)$$
<!-- Add your space complexity here, e.g. $$O(n)$$ -->

# Code
```java []
class Solution {
    public int largestSumAfterKNegations(int[] nums, int k) {
        Arrays.sort(nums);
        boolean hasZero = false;
        int min = Integer.MAX_VALUE;

        for (int i = 0; i < nums.length; i++) {
            // make negative number positive to maximize sum
            if (k > 0 && nums[i] < 0) {
                nums[i] *= -1;
                k--;
            } else if (nums[i] == 0) {
                hasZero = true;
            }
            min = Math.min(min, nums[i]);
        }
 
        int sum = IntStream.of(nums).sum();
        // If array has zero then we can apply the operation k times on it
        // If k is even, then applying operation k times doesnt affect
        if(hasZero || (k % 2 == 0)) {
            return sum;
        }

        // If k is odd then we negate the minimum element, since we already considered
        // in sum, we have to reduce it two times.
        return sum - 2 * min;
    }
}

```
['Java']