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

java 版本长度为1的时候也要考虑k的奇偶性才能直接return吧
This commit is contained in:
SkyLazy
2021-06-04 14:39:03 +08:00
committed by GitHub
parent a00f188ddb
commit e5ee38f826

View File

@ -102,7 +102,7 @@ Java
```java
class Solution {
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);
int sum = 0;
int idx = 0;