You are given an integer array named nums.
Your task is to find the contiguous subarray within nums that has the largest possible sum.
Remember that:
Return the largest sum found.
[1]
1
The subarray [1] has the largest sum = 1.
[4, -1, 2, 1, -5, 4]
6
The subarray [4, -1, 2, 1] has the largest sum of 6.
[5, -1, 4, -2, 6]
12
Although there are negative numbers, the entire array [5, -1, 4, -2, 6] forms the maximum subarray with a sum of 12.
[1]
1