← 返回 google 的题目列表Minimum Absolute Sum
类型:online_judge
Given an integer array A, you can choose at most one element and multiply it by -1. The goal is to make the sum of all elements in the array as close to 0 as possible. Return this minimum absolute sum.
Input
An integer array A.
Output
The minimum absolute sum after one adjustment.
Example
Input: [2, -3, 1]
Output: 0
Constraints
The length of the array is between [1, 1000].
Each element is in the range [-1000, 1000].
Example
Input
3
2 -3 1