This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Maximum Subarray (Kadane's Algorithm) | |
------------------------------------- | |
Provides two APIs: | |
- max_subarray_sum(nums): returns the maximum subarray sum (int) | |
- max_subarray_with_indices(nums): returns (max_sum, start_idx, end_idx) inclusive | |
Both handle all-negative arrays correctly. Empty input raises ValueError. | |
Time: O(n), Space: O(1). |