3ms t.c. java solution
\nPLEASE UPVOTE IF YOU LIKE.\n\n        Arrays.sort(nums);\n\n        int sum = 0;\n        int min = 100;\n        int left = 0;\n        int right = nums.leng
```\nPLEASE UPVOTE IF YOU LIKE.\n```\n        Arrays.sort(nums);\n\n        int sum = 0;\n        int min = 100;\n        int left = 0;\n        int right = nums.length - 1;\n\n        while (left <= right){\n            min = Math.min(min, Math.abs(nums[left]));\n            if (k == 0) {\n                sum += nums[left];\n                left++;\n            }\n            else if (nums[right] < Math.abs(nums[left])){\n                sum += Math.abs(nums[left]);\n                left++;\n                k--;\n            }\n            else {\n                sum += nums[right];\n                right--;\n            }\n        }\n\n        return k % 2 == 0 ? sum : sum - 2 * min;
['Java']