[C++/Python] I guaranteed that this is the BEST "Greedy" solution you've ever seen . O(NlogN)
\nC++ []\nclass Solution {\npublic:\n    int largestSumAfterKNegations(vector<int>& v, int k) {\n        sort(v.begin(), v.end());\n        for(int i=0;i<v.size
\n```C++ []\nclass Solution {\npublic:\n    int largestSumAfterKNegations(vector<int>& v, int k) {\n        sort(v.begin(), v.end());\n        for(int i=0;i<v.size() && v[i]<0 && k>0 ;i++){\n            v[i]*=-1;\n            k--;\n        }\n        int min=INT_MAX;\n        int sum=0;\n        for(int i=0;i<v.size();i++){\n            min=std::min(min,v[i]);\n            sum+=v[i];\n        }\n        if(k%2!=0) sum-=min*2;\n        return sum;\n    }\n};\n```\n```Python []\nclass Solution:\n    def largestSumAfterKNegations(self, v: List[int], k: int) -> int:\n        v.sort()\n        for i in range(len(v)):\n            if v[i] < 0 and k > 0:\n                v[i] *= -1\n                k -= 1\n        min_val = min(v)\n        sum_val = sum(v)\n        if k % 2 != 0:\n            sum_val -= min_val * 2\n        return sum_val\n```\n
['C++']