Maximum Subarray
Medium๐ท๏ธ Dynamic programming๐ Greedy & Dynamic Programming
๐งฉ The problem
Return the largest sum of any non-empty contiguous subarray.
Examples
[-2, 1, -3, 4, -1, 2, 1, -5, 4] โ 6 (the subarray [4, -1, 2, 1])
๐ฏ Aim for: O(n) time ยท O(1) space (Kadaneโs algorithm)
โ๏ธ Write your solution
Pick a language, press Run to try it, then Run tests to check it against every test case โ just like a coding interview.