Maximum Sum SubArray (Kadane's algorithm) With Algorithm & Python Code

preview_player
Показать описание
Maximum Sum SubArray (Kadane's algorithm) (Largest Sum Contiguous SubArray)
Time Complexity - O(n)
Space Complexity - O(1)

-~-~~-~~~-~~-~-
Please watch: "LRU Cache (With Python Code) "
-~-~~-~~~-~~-~-
Рекомендации по теме
Комментарии
Автор

Explained each and every point with patience .Thankyou ☺

srikanthchebrolu
Автор

this is an excellent video was able to completely understand the algorithm well explained!

davidogunronbi
Автор

I don't quite understand why when the current sum is negative it needs to be turned to 0? Can you further explain? Thank you

angelortiz
Автор

thanks for your explanation, it is easy to understand

vinaykumarreddybandapalli
Автор

Can you please reply for the query..
If the input is taken from the user then how we can assign it in runtime.

gummadinagalakshmi
Автор

Thank you so much. I found it very informative

Akkidhruv
Автор

Hello Ma'am, I've tried running this code in Jupyter Notebook, but it is showing an error

please lemme know how I can rectify it?

girishchitte
Автор

Find the kth smallest element from unsorted array of n numbers where n>>k .Basically this question is to reduce infinite input problem to finite/constant memory/storage mam plz make video to solve this above problem

jeevapriya
Автор

excellent explanation, thank you so much :)

pythonenthusiast
Автор

how about whole array having negative numbers

arnabpersonal
Автор

can you please solve the same thing when all input values are negative?

poojakumari-kcjm
Автор

def max_sum(arr):
curr_value = 0
max_value = arr[0]

for i in range(len(arr)):
curr_value += arr[i]

# Always update max_value to track the highest sum so far
max_value = max(max_value, curr_value)

# Reset curr_value if it goes negative
if curr_value < 0:
curr_value = 0

return max_value

debojitmandal
Автор

if we want negative value in max so far

sanskarshukla