mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-09 03:34:02 +08:00
Merge pull request #322 from SkyLazy/patch-1
Update 1005.K次取反后最大化的数组和.md
This commit is contained in:
@ -102,7 +102,7 @@ Java:
|
|||||||
```java
|
```java
|
||||||
class Solution {
|
class Solution {
|
||||||
public int largestSumAfterKNegations(int[] A, int K) {
|
public int largestSumAfterKNegations(int[] A, int K) {
|
||||||
if (A.length == 1) return A[0];
|
if (A.length == 1) return k % 2 == 0 ? A[0] : -A[0];
|
||||||
Arrays.sort(A);
|
Arrays.sort(A);
|
||||||
int sum = 0;
|
int sum = 0;
|
||||||
int idx = 0;
|
int idx = 0;
|
||||||
|
Reference in New Issue
Block a user