As reported: eBay MTS (Bangalore hiring drive, 2025): find the maximum subarray sum; the array may contain negative numbers. Kadane's algorithm was used.
Given an integer array nums, return the largest sum of a non-empty contiguous subarray.
This is LeetCode 53 — Maximum Subarray.
Example 1
nums = [-2,1,-3,4,-1,2,1,-5,4] -> 6 ([4,-1,2,1])
Example 2
nums = [5,4,-1,7,8] -> 23
Constraints: 1 ≤ n ≤ 10^5; -10^4 ≤ nums[i] ≤ 10^4.
Code runner format: one line, nums as JSON. Implement maxSubArray(nums); the harness prints the sum.