input: Write a python function to find the maximum subarray sum using Kadane's algorithm.
  assert max_subarray([1, -2, 3, 4, -1, 2, 1, -5, 4]) == 9
  assert max_subarray([-2, -3, 4, -1, -2, 1, 5, -3]) == 7
  assert max_subarray([1, 2, 3, 4, 5]) == 15
  assert max_subarray([-1, -2, -3, -4]) == -1
output: def max_subarray(nums):
      max_current = max_global = nums[0]
      for num in nums[1:]:
          max_current = max(num, max_current + num)
          if max_current > max_global:
              max_global = max_current
      return max_global