Given an array of integers, write a program to find the maximum sum of a subarray within the array.
Input:
Output:
Example 1
Input: 5 -2 1 -3 4 -1
Output: 4
The maximum sum of a subarray is 4, which is the sum of the subarray [4].
Constraints
Hints
Given an array of integers, write a program to find the maximum sum of a subarray within the array.
Input:
Output:
Example 1
Input: 5 -2 1 -3 4 -1
Output: 4
The maximum sum of a subarray is 4, which is the sum of the subarray [4].
Constraints
Hints