0% found this document useful (0 votes)
20 views1 page

Maximum Subarray

The document describes a problem to find the maximum sum of a contiguous subarray in a given integer array. It provides examples of the problem with different input arrays and expected outputs. The constraints specify the length of the input array can range from 1 to 105 elements, and each element value can range from -104 to 104.

Uploaded by

PRAVIN G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views1 page

Maximum Subarray

The document describes a problem to find the maximum sum of a contiguous subarray in a given integer array. It provides examples of the problem with different input arrays and expected outputs. The constraints specify the length of the input array can range from 1 to 105 elements, and each element value can range from -104 to 104.

Uploaded by

PRAVIN G
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

https://leetcode.

com/problems/maximum-subarray/
53. Maximum Subarray
Easy
Add to List

Share
Given an integer array nums, find the contiguous subarray (containing at least one
number) which has the largest sum and return its sum.

A subarray is a contiguous part of an array.

Example 1:

Input: nums = [-2,1,-3,4,-1,2,1,-5,4]


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

Input: nums = [1]


Output: 1
Example 3:

Input: nums = [5,4,-1,7,8]


Output: 23

Constraints:

1 <= nums.length <= 105


-104 <= nums[i] <= 104

You might also like