int largestSumAfterKNegations(int* nums, int numsSize, int k) {
int t[201]={0};
int sum=0;
for(int i=0;i<numsSize;i++){
t[100+nums[i]]++;
sum+=nums[i];
}
while(k>0){
for(int i=0;i<201;i++){
if(t[i]!=0){
t[i]--;
t[200-i]++;
int temp=i-100;
if(temp<0) {
sum+=2*abs(temp);
}else{
sum-=2*temp;
}
break;
}
}
k--;
}
return sum;
}
结果;
标签:最大化,numsSize,int,取反,数组,1005 From: https://www.cnblogs.com/llllmz/p/18064980