Kadanes Algorithm - The best and the most efficient way to find the maximum sum of a subarray

preview_player
Показать описание
Kadane's algorithm

Problem link :

Course link:

Hi, thanks for watching our video about Strings in C++
In this video we’ll walk you through:
- Arrays
- Kadanes algorithm
- Solution

TIMESTAMPS
0:00 Intro
02:55 Explanation begins
11:40 IDE solution

ABOUT OUR CHANNEL
Our channel is all about Programming. We cover lots of cool stuff such as solution to problems, concept explanation and tricks to master CP
Check out our channel here:
Don’t forget to subscribe!

CHECK OUT OUR OTHER Playlists

GeeksforGeeks playlist:

Complete C++ Course playlist:

CodeChef Playlist:

LeetCode problems

HackerRank playlist:

FIND US AT

GET IN TOUCH
Рекомендации по теме
Комментарии
Автор

Help me
Possibly your code doesn't work correctly for multiple test-cases (TCs).

The first test case where your code failed:

Input:

int sum=0;
int maximum =
for(int i=0; i<n; i++){
sum += arr[i];
maximum = max(maximum, sum);
if(sum < 0){
sum = 0;
}

}
return maximum;

rohanthakran
visit shbcf.ru