1005. Maximize Sum Of Array After K Negations
https://leetcode.com/problems/maximize-sum-of-array-after-k-negations
Description
Given an integer array nums
and an integer k
, modify the array in the following way:
choose an index
i
and replacenums[i]
with-nums[i]
.
You should apply this process exactly k
times. You may choose the same index i
multiple times.
Return the largest possible sum of the array after modifying it in this way.
Example 1:
Example 2:
Example 3:
Constraints:
1 <= nums.length <= 104
-100 <= nums[i] <= 100
1 <= k <= 104
ac
Last updated