<s>[INST] Given an array of integers, find the maximum sum of a contiguous subarray within the array.

Example:
Input: [-2,1,-3,4,-1,2,1,-5,4]
Output: 6

Explanation: [4,-1,2,1] has the largest sum = 6.

To solve this problem, we will use Kadane's algorithm, which iterates through the array and at each step, it decides whether to continue the current subarray or start a new one.

Here is my attempt:

```python
def maximum_subarray_sum(nums):
    max_so_far = float('-inf')
    max_ending_here = 0
    for num in nums:
        max_ending_here += num
        if max_so_far < max_ending_here:
            max_so_far = max_ending_here
        if max_ending_here < 0:
            max_ending_here = 0
    return max_so_far

print(maximum_subarray_sum([-2,1,-3,4,-1,2,1,-5,4])) # Output: 6
```

Please provide feedback on the code.

Here are some key aspects I would like to know:

*   Does the solution correctly implement Kadane's algorithm?[/INST]