Error: cannot solve it. Change 0 to -1, so that it become a zero center problem. Assume s[i] = x, and s[j] = x, so that: s[i] + n[i + 1] … + n[j] = s[j] i.e. n[i + 1] + … + n[j] = 0 Also, if s[j] == 0, we can treat it as corner case. Ba
Error:
cannot solve it. Change 0 to -1, so that it become a zero center problem.
Assume s[i] = x, and s[j] = x, so that: s[i] + n[i + 1] … + n[j] =
s[j] i.e. n[i + 1] + … + n[j] = 0Also, if s[j] == 0, we can treat it as corner case.
Base on that, we build a map to keep track of sum, if that sum appear before or current sum = 0, compare it to our current max.