As reported: Omnissa (formerly VMware) MTS-3 loop (2026), round 3 DSA, one of two problems: maximum subarray sum (Kadane's algorithm).
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 = [1] -> 1
Constraints: 1 ≤ nums.length ≤ 10^5; -10^4 ≤ nums[i] ≤ 10^4.
Code runner format: one JSON value: nums (LeetCode's format). Implement maxSubArray(nums); the harness prints the sum.