error:
cannot solve it.

assume T[i, j] = k, where T[i, j] is the sum of nums[i] to nums[j]. So the equations can transform to: S[j] - S[i - 1] = k. And if we know that preious the occurs of S[j] - k, which is the times of sum equal to S[i - 1]. We can easily get the answer: use a map to keep track current sum, if sum - k occur previously, accumulate it to answer.


update:
remember: initial m[0] = 1;