// Maximum Subarray — MEDIUM
// Category: array
Given an integer array `nums`, find the subarray with the largest sum, and return its sum.
A subarray is a contiguous non-empty part of an array.
Hint: Use Kadane's algorithm — track the current sum and reset when it goes negative.
Example: nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
Output: 6