Straightforward Java O(nlogn) and constant space with thinking process
The idea is pretty simple:\n1. The sum maximizes when all numbers are positive.\n2. If K >= neg(count of negative numbers), we use neg flips to make all negativ
The idea is pretty simple:\n1. The sum maximizes when all numbers are positive.\n2. If K >= neg(count of negative numbers), we use neg flips to make all negative numbers to positive. If (K - neg) % 2 == 0, good, nothing will be changed; If not, flip the number that has min Math.abs(number) once. \n3. If K < neg, we just need to flip the first K negative numbers in a sorted array. \n```\n    public int largestSumAfterKNegations(int[] A, int K) {\n        int neg = 0, sum = 0, close = Integer.MAX_VALUE;\n        for(int i : A){\n            if(i < 0) neg++;\n            if(Math.abs(i) < close) close = Math.abs(i);\n        }\n        if(K >= neg){\n            int remain = K - neg;\n            for(int i : A) sum += Math.abs(i);\n            return remain % 2 == 0? sum : sum - 2*close;\n        }\n        else {\n            Arrays.sort(A);\n            for(int i : A){\n                if(K > 0){\n                    sum += Math.abs(i);\n                    K--;\n                }\n                else sum += i;\n            }\n            return sum;\n        }\n    }\n```
[]