Solution
C++ []\nclass Solution {\npublic:\nlong long getSum(vector<int> negate, vector<int>positive)\n{\n    long long sum =0;\n                for(int i=0;i<negate.siz
```C++ []\nclass Solution {\npublic:\nlong long getSum(vector<int> negate, vector<int>positive)\n{\n    long long sum =0;\n                for(int i=0;i<negate.size();i++)\n            {\n                sum+=negate[i];\n            }\n        for(int i=0;i<positive.size();i++)\n            {\n                sum+=positive[i];\n            }\n            return sum;\n}\n    int largestSumAfterKNegations(vector<int>& nums, int k) {\n   vector<int>negate;\n   vector<int>positive;\n    for(int i=0;i<nums.size();i++)\n    {\n        if(nums[i]>=0)\n        {\n            positive.push_back(nums[i]);\n        }\n        else{\n            negate.push_back(nums[i]);\n        }\n    }\n    if(negate.size()>k)\n    {\n        sort(negate.begin(), negate.end());\n        for(int i=0;i<k;i++)\n        {\n            negate[i] = abs(negate[i]);\n        }\n        return getSum(negate, positive);\n    } else {\n        for(int i=0;i<negate.size();i++)\n        {\n            negate[i] = abs(negate[i]);\n        }\n        int remainingcount = k-negate.size();\n        if(remainingcount%2==0)\n        {\n            return getSum(negate, positive);\n        } else {\n        int mini = INT_MAX;\n            for(int i=0;i<negate.size();i++)\n            {\n                mini = min(mini, negate[i]);\n            }\n        for(int i=0;i<positive.size();i++)\n            {\n                mini = min(mini, positive[i]);\n            }\ncout<<mini<<endl;\ncout<<getSum(negate, positive)<<endl;\n            return (getSum(negate, positive) - 2*mini);\n        }\n    }\n    }\n};\n```\n\n```Python3 []\nclass Solution:\n    def largestSumAfterKNegations(self, nums: List[int], k: int) -> int:\n        nums = sorted(nums)\n        for i in range(len(nums)):\n            if nums[i] < 0 and k > 0:\n                nums[i] = -nums[i]\n                k -= 1\n        nums = sorted(nums)\n        if k > 0 and k % 2 != 0: \n            nums[0] = -nums[0]\n        return sum(nums)\n```\n\n```Java []\nclass Solution {\n    public int largestSumAfterKNegations(int[] nums, int k) {\n        int[] numbers = new int[201];\n        int sum = 0;\n        int maxAbs = 0;\n        for (int n: nums) {\n            maxAbs = Math.max(maxAbs, Math.abs(n));\n            numbers[100 + n]++;\n            sum += n;\n        }\n        if (maxAbs == 0) {\n            return 0;\n        }\n        while (k-- != 0) {\n            int i = 100 - maxAbs;\n            while (numbers[i] == 0) {\n                i++;\n            }\n            numbers[i]--;\n            numbers[200 - i]++;\n            sum -= 2 * (i - 100);\n        }\n        return sum;\n    }\n}\n```
['C++', 'Java', 'Python3']