Your browser does not seem to support JavaScript. As a result, your viewing experience will be diminished, and you have been placed in read-only mode.

Please download a browser that supports JavaScript, or enable it if it's disabled (i.e. NoScript).

int maxSubArray(int A[], int n) { int max = A[0], sum = A[0]; for (int i = 1; i < n; ++i) { sum += A[i]; if (A[i] > sum) sum = A[i]; if (sum > max) max = sum; } return max; }

Could you give some explanation on that solution? Thx!

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.