Search
Max Sum Contiguous Subarray - Interviewbit Solution
- illuminati
- Sep 1, 2020
- 1 min read
Updated: Sep 8, 2020
Problem: Max Sum Contiguous Subarray
Problem Description:
Find the contiguous subarray within an array, A of length N which has the largest sum.
Input Format:
The first and the only argument contains an integer array, A.
Output Format:
Return an integer representing the maximum possible sum of the contiguous subarray.
Constraints:
1 <= N <= 1e6
-1000 <= A[i] <= 1000
For example:
Input 1: A = [1, 2, 3, 4, -10]
Output 1: 10
Explanation 1: The subarray [1, 2, 3, 4] has the maximum possible
sum of 10.
Input 2: A = [-2, 1, -3, 4, -1, 2, 1, -5, 4]
Output 2: 6
Explanation 2: The subarray [4,-1,2,1] has the maximum possible sum
of 6.
Solution:
Recent Posts
See AllYou are given an array of N non-negative integers, A0, A1 ,…, AN-1.Considering each array element Ai as the edge length of some line segment
Given an array S of n integers, are there elements a, b, c in S such that a + b + c = 0? Find all unique triplets in the array which gives
Comments