Consider an operation where you remove exactly one element from nums. The remaining elements keep their order.
Return true if, after the operation, the remaining array can be split into a non-empty prefix and a non-empty suffix that have equal sums. Otherwise, return false.
Examples
Example 1
Input: nums = [1, 4, 2, 3]
Output: true
Explanation: Removing 4 leaves [1, 2, 3]. The prefix [1, 2] and the suffix [3] both sum to 3.
Example 2
Input: nums = [1, 2, 3]
Output: false
Explanation: The possible remaining arrays are [2, 3], [1, 3], and [1, 2]. In each one the two elements differ, so no split has equal sums.
Constraints
3≤nums.length≤105
−104≤nums[i]≤104
Loading editor...
Log in to run your code. Your draft is saved in this browser.Log inSign up