Skip to main content

Kadane (DP)

Learn Kadane (DP) (Dynamic Programming, Advanced DSA) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

Kadane's as a Formal DP Recurrence Kadane's Algorithm IS dynamic programming, just usually taught without the DP framing: define dp[i] = the maximum subarray sum ENDING exactly at index i. The recurrence dp[i] = max(arr[i], dp[i-1] + arr[i]) is the same "extend or restart" idea, just written as an explicit DP array instead of two rolling variables.

More lessons in Dynamic Programming