Input
nums = [-2,1,-3,4,-1,2,1,-5,4]
Output
6
Explanation
We need to find a contiguous subarray with the maximum possible sum.
If we look at the array, the subarray:
[4, -1, 2, 1] has the largest sum.
4 + (-1) + 2 + 1 = 6
So, the maximum subarray sum is 6.