You are given an integer array nums (values may repeat and may be negative). You must remove exactly one element (remove one index). The remaining elements keep their original relative order.
A pivot index in an array is an index p such that:
sum(array[0 .. p-1]) == sum(array[p+1 .. end])
(i.e., the sum of elements strictly to the left of p equals the sum of elements strictly to the right of p).
Task: Return True if there exists a way to remove exactly one element from nums such that the resulting array has at least one pivot index. Otherwise return False.
Notes:
n-1
.
Example format (not necessarily True):
nums = [2, 1, 3, 1, 2]
Constraints (you may assume typical interview bounds): 2 <= n <= 2e5, -1e9 <= nums[i] <= 1e9.