Easy adn Simple Solution
\nclass Solution {\npublic:\n    int largestSumAfterKNegations(vector<int>& a, int k) {\n        sort(a.begin(),a.end());      // sorting in begining\n        i
```\nclass Solution {\npublic:\n    int largestSumAfterKNegations(vector<int>& a, int k) {\n        sort(a.begin(),a.end());      // sorting in begining\n        int sum=0;\n        for(int i=0;i<a.size()&&k>0;i++)\n        {\n            if(a[i]<0)       // for all negative elements\n            {\n                a[i]=-a[i];\n                k--;\n            }\n            else \n                break;      // else breaking out of loop\n        }\n        sort(a.begin(),a.end());           // sorting again to find out the smallest element in the modified array\n        for(int i=1;i<a.size();i++)            // calculating sum except the smallest element i.e a[0]\n                sum+=a[i];\n        if(k%2==0)\n            return sum+a[0];                    // adding smallest element as it is if k is even\n        else\n            return sum-a[0];                   // adding smallest element after changinf sign if k is odd\n    }\n};\n```
['C', 'Sorting', 'C++']