JavaScript easy to understand solution which beats 100%
\nfunction largestSumAfterKNegations(a, k) {\n    a.sort((a, b) => a - b);\n    let index = 0, sum = 0;\n    while(k) {\n        a[index] = (0 - a[index]);\n   
```\nfunction largestSumAfterKNegations(a, k) {\n    a.sort((a, b) => a - b);\n    let index = 0, sum = 0;\n    while(k) {\n        a[index] = (0 - a[index]);\n        if(index + 1 < a.length && a[index + 1] < a[index]) {\n            index++;\n        }\n        k--;\n    }\n    return a.reduce((item, sum) => sum + item, 0);\n};\n```
[]