Given an integer array nums, identify a non-empty consecutive segment whose total is as large as possible, then return that total.
Implement maxSubArray(nums: int[]) -> int.
An integer array named nums.
The greatest sum obtainable from a contiguous subarray.
Input: [-3,2,-1,5,-4,3],
Output: 6
Explanation: [2,-1,5] produces the maximum sum, which is 6.
nums = [-3, 2, -1, 5, -4, 3]6
The input array nums = [-3, 2, -1, 5, -4, 3].
1 <= nums.length <= 10^5-10^4 <= nums[i] <= 10^4Input: [-4,3,-1,4,-6,2]
Output: 6
nums = [-3, 2, -1, 5, -4, 3]6
The input array nums = [-3, 2, -1, 5, -4, 3].