Maximum Subarray Sum (Algorithm & Java Code)

preview_player
Показать описание
Given an integer array, find the contiguous subarray (containing at least one number) which has the largest sum and return its sum. This code works both for positive and negative cases.

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

Exactly what I was looking for.. Thank you very much sir

ritabratanag
Автор

If arr = [1]; the program outputs 2 which is not correct.

besuynaitsa
Автор

sir i need the code position of the first and last elements to the sum

walidmebarki
Автор

What If all the elements are negative then it will always return wrong value

dheerajsahu
Автор

You did not get the contiguous subarray which was asked in the question.? Pleasse elaborate/

MohdDanish-kvry
Автор

Bu how do you keep track of the contiguous array and return the contiguous array?

sheriffcrandy
Автор

Is this code make two pointers array apporch.

NidhiKumari-ibow
Автор

{-1, -10, 10, -1, 10, -18}
Is this code valid for above testcase ?

varuns
Автор

If all number will be positive then it will not

jobshorts
Автор

Code link is present in the description box.

ProgrammingTutorialsM
Автор

Sir if you can explain in hindi it would be more better and you will be getting so many more views

Aish-dmnp
Автор

questions are good but who so ever is explaining these problems needs to clear his hesitation and concepts then properly prepare for presentation before explaination.

samarchourasia
Автор

Well explained, but improve your english please.

adrianiordache