Skip to content

Commit 15ca61a

Browse files
authored
Update 1005.K次取反后最大化的数组和.md
保持Java代码的一致性,使用stream api来返回累加结果。
1 parent a7d3ab6 commit 15ca61a

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

problems/1005.K次取反后最大化的数组和.md

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,8 @@ class Solution {
117117
}
118118
// 如果K还大于0,那么反复转变数值最小的元素,将K用完
119119
if (k % 2 == 1) nums[len - 1] = -nums[len - 1];
120-
int result = 0;
121-
for (int a : nums) {
122-
result += a;
123-
}
124-
return result;
120+
121+
return Arrays.stream(nums).sum();
125122
}
126123
}
127124
```

0 commit comments

Comments
 (0)