Minimum Absolute Sum Difference

You are given an array of integers nums, which may contain positive numbers, negative numbers, and zeros. Pick a single cut position i such that 1 <= i <= n-1, splitting the array into two non-empty parts:

  • prefix nums[0..i-1]
  • suffix nums[i..n-1]

For a given cut, compute the absolute difference between the sum of the prefix and the sum of the suffix: |sum(prefix) - sum(suffix)|.

Return the minimum value of this absolute difference over all valid cut positions.

If the array has fewer than two elements, no cut exists, so return the absolute value of the single element (or 0 for an empty array).

Examples
Input: [1,2,3,4]
Output: 2
Hints
Related Problems

Minimum Absolute Sum Difference

You are given an array of integers `nums`, which may contain positive numbers,