Solution: Maximum Subarray Sum

Solution # 1

A naive solution to this problem is:

  1. Find the sum of all possible contiguous subarrays.
  2. Find the maximum of those sums.
  3. Return the sum.

This approach can easily be implemented using two for loops like this:

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.