Given an integer array nums, return the maximum sum of any non-empty contiguous subarray.
Input / output
nums: integer[]Examples
[-2,1,-3,4,-1,2,1,-5,4] returns 6 from [4,-1,2,1].[-5,-2,-8] returns -2; choosing no elements is not allowed.Constraints
1 <= nums.length <= 100,000-10,000 <= nums[i] <= 10,000Follow-up Can you derive Kadane's algorithm from the choice to extend the previous subarray or start a new one?