Home
Topics
Practice
Roadmap
DSA Tracker
Code Editor
Tech Blogs
More
Sign in
Get started
Loading question...
Feedback
Maximum Subarray
Medium
00:00
0 users online
Share
Description
Solution
Submissions
Discussion
Given an array, find the contiguous subarray with the largest sum.
Sample Input:
[-2,1,-3,4,-1,2,1,-5,4]
Sample Output:
6
Hints
Hint 1
Use Kadane's algorithm
Hint 2
Keep track of current sum and maximum sum
Hint 3
Reset current sum to 0 if it becomes negative
Code Editor
Reset
Run
Save
Loading...