arin2002 / Hacktoberfest-2022

For hacktoberfest do fork and star the repo to participate otherwise you won't be able to participate.......You can follow me for more updates :)
MIT License
103 stars 317 forks source link

Create KadanesAlgo.cpp #961

Closed shxxxam closed 10 months ago

shxxxam commented 10 months ago

This code is a C++ program that finds the maximum sum of a subarray within a given array. It uses Kadane's algorithm.

This program calculates the maximum sum of a subarray within the given array arr. The constraints are defined as n <= 100. Here's what the code does: 1) It initializes an array arr with sample values. 2) It calculates the length of the array n. 3) The code uses Kadane's algorithm to find the maximum subarray sum. It iterates through the array, keeping track of the maximum subarray sum (maxSum) and the maximum subarray sum ending at the current position (x). 4) The result is printed, showing the maximum sum of a subarray.