#3698

Split Array With Minimum Difference

medium · 33.6% accepted · 101 likes · top 11%

array · prefix sum

Description

You are given an integer array nums.

Split the array into exactly two subarrays, left and right, such that left is strictly increasing and right is strictly decreasing.

Return the minimum possible absolute difference between the sums of left and right. If no valid split exists, return -1.

Solution