Maximum Contiguous Subarray Sum
Find the largest sum of any contiguous, nonempty part of an array.
The problem
Implement Solution.maxSubArray(nums). nums holds between 1 and 100,000 integers, and each one may be negative. A subarray is a contiguous, nonempty slice of nums. Return the largest sum any subarray can have. For example, in [-2, 1, -3, 4, -1, 2, 1, -5, 4] the best subarray is [4, -1, 2, 1] with sum 6.
Starter code
class Solution:
def maxSubArray(self, nums):
passPublic examples
nums = [-2, 1, -3, 4, -1, 2, 1, -5, 4]gives6nums = [0, 0]gives0nums = [-10, 2, 3]gives5
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
