优化 1005.K次取反后最大化的数组和 python3版本

优化 1005.K次取反后最大化的数组和 python3版本
This commit is contained in:
jojoo15
2021-06-09 23:08:35 +02:00
committed by GitHub
parent e470235464
commit 9f3990a78f

View File

@ -133,7 +133,7 @@ class Solution:
A[i] *= -1
K -= 1
if K > 0:
A[len(A) - 1] *= ((-1)**K)
A[-1] *= (-1)**K #取A最后一个数只需要写-1
return sum(A)
```