Merge pull request #322 from SkyLazy/patch-1
Update 1005.K次取反后最大化的数组和.md
This commit is contained in:
commit
c586e0016a
|
|
@ -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;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue