优化 1005.K次取反后最大化的数组和 python3版本
优化 1005.K次取反后最大化的数组和 python3版本
This commit is contained in:
parent
e470235464
commit
9f3990a78f
|
|
@ -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)
|
||||
```
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue