mirror of
https://github.com/youngyangyang04/leetcode-master.git
synced 2025-07-08 16:54:50 +08:00
Merge pull request #377 from jojoo15/patch-35
优化 1005.K次取反后最大化的数组和 python3版本
This commit is contained in:
@ -133,7 +133,7 @@ class Solution:
|
|||||||
A[i] *= -1
|
A[i] *= -1
|
||||||
K -= 1
|
K -= 1
|
||||||
if K > 0:
|
if K > 0:
|
||||||
A[len(A) - 1] *= ((-1)**K)
|
A[-1] *= (-1)**K #取A最后一个数只需要写-1
|
||||||
return sum(A)
|
return sum(A)
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user