WeBeginners-Community / DocBook

Documentations of Html to every open source technologies. It's a low-code repository
30 stars 54 forks source link

Kadane Algorithm #179

Closed Vanraj8169 closed 1 year ago

Vanraj8169 commented 1 year ago

Description

Kadane's Algorithm is an iterative dynamic programming algorithm. It calculates the maximum sum subarray ending at a particular position by using the maximum sum subarray ending at the previous position.

Problem Statement

Given an array arr[] of size N. The task is to find the sum of the contiguous subarray within a arr[] with the largest sum.

Examples

Input: [-3, -4, 5, -1, 2, -4, 6, -1] Output: 8 Explanation: Subarray [5, -1, 2, -4, 6] is the max sum contiguous subarray with sum 8.

Fixes: #170

Type of change

Checklist:

ATTACH SCREEN-SHOTS / DEPLOYMENT LINK

image

OUTPUT

image