Minimum Absolute Sum
Problem Overview
- Given an integer array A, you may multiply at most one element by -1 to make the total sum as close to zero as possible, returning the minimum absolute sum.
- Constraints: N in [1..100000], elements in [-1000..1000]; output is the minimal absolute value of the sum after the single optional flip.
- Context: Models balancing a net total or minimizing deviation in real-world aggregates.
- From Google interviews; a coding interview problem and common interview question.
Example
Unlock to view complete problem details
and practice with sample input/output
Was this article helpful?
View Test Cases & Run Code requires membership
Input Variables
Execution Result:
