sum
such that sum[i]
holds the sum of elements from nums[0]
to nums[i]
.j
.j
, create a new HashSet set
.i
that are less than j
.sum[i-1]
(sum of the first part) is equal to sum[j-1] - sum[i]
(sum of the second part), add sum[i-1]
to set
.k
that are greater than j
.sum[n-1] - sum[k]
(sum of the fourth part) is equal to sum[k-1] - sum[j]
(sum of the third part) and the sum exists in set
, return true
.false
.