Dynamic Programming - Maximum Subarray Problem | Intermediate Level

Опубликовано: 26 Октябрь 2023
на канале: Tutorial Horizon
2,260
13

Complete Article - https://tutorialhorizon.com/algorithm...

Dynamic Programming -    • What is Dynamic Programming? A Step-b...  

Kadane Algorithm -    • Kadane's Algorithm: A Simple and Effi...  


The maximum subarray problem is the task of finding the contiguous subarray within a one-dimensional array of numbers that has the largest sum.

Example:

int [] A = {−2, 1, −3, 4, −1, 2, 1, −5, 4};

Output: contiguous subarray with the largest sum is 4, −1, 2, 1, with sum 6.