Java solution O(1) space one pass.
Traverse the array, track the number of negative elements\nIf number of negative elements is smaller than K, we can flip it to positive, otherwise, keep it as n
Traverse the array, track the number of negative elements\nIf number of negative elements is smaller than K, we can flip it to positive, otherwise, keep it as negative.\nAfter the traversal, if we still have K - count flips to finish, it means we have flipped all negative elements, and have to touch a positive element. if K - count is even, flip any element is ok since it does not change anything. If K - count is odd, choose the smallest element which we have kept tracking in the traversal by minPositive.\n\n```java\n        Arrays.sort(A);\n        int count = 0, sum = 0, minPositive = Integer.MAX_VALUE;\n        for (int num : A) {\n            if (num < 0 && ++count <= K) {\n                num = -num;\n            }\n            sum += num;\n            minPositive = Math.min(minPositive, num);\n        }\n        if (count > K || (K - count) % 2 == 0) {\n            return sum;\n        } else {\n            return sum - minPositive * 2;\n        }\n```
[]