One Pager Cheat Sheet
- We're going to learn about
Kadane's Algorithmand its implementation in Python, JavaScript, and Java, in order to solve the Maximum Subarray Problem. - Kadane's Algorithm is a form of Dynamic Programming developed by Joseph Born Kadane which provides an optimal solution for the
Maximum Subarray Problem. - The
Maximum Subarray Problemis to find the largest sum of a contiguous subarray in an input array of size n. - The Brute Force approach can be used to calculate the largest sum of a contiguous subarray in an array by comparing all possible subarrays and setting the max sum to a globalMaxSum variable, with a time complexity of
O(n^2). - The time complexity of this algorithm is O(n2), as it requires two loops (
outer loop with indexifrom 0 to n-1andinner loop with indexjfrom j set to i to n-1). - Kadene's Algorithm is an
optimal approachwith time complexityO(n), to the maximum subarray problem which is found by looping through the array, comparing thelocal Max Sums, and updating theglobal Max Sumat each iteration. - Kadene's Algorithm to find the largest sum of a contiguous subarray has a time complexity of O(n) due to its single loop iteration from
index 0toindex n-1. - We solved the
Maximum Subarray Problemin an optimal way usingKadene's Algorithm.


