Maximum Product Subarray | LeetCode 152 | C++, Java, Python

preview_player
Показать описание

**** Best Books For Data Structures & Algorithms for Interviews:**********
*****************************************************************************

September LeetCoding Challenge | Problem 11 | Maximum Product Subarray | 11 September,
Facebook Coding Interview question,
google coding interview question,
leetcode,
Maximum Product Subarray,
Maximum Product Subarray c++,
Maximum Product Subarray Java,
Maximum Product Subarray python,
Maximum Product Subarray solution,
152. Maximum Product Subarray,

#CodingInterview #LeetCode #Google #Amazon #MaximumProductSum
Рекомендации по теме
Комментарии
Автор

Crystal clear explanation, 19min well spent. Appreciate the effort

kushal
Автор

sir, how do you remember all these algorithms? What is the best way to remember and practice these algorithms? How to get better at these everyday ? I do it everyday, but somehow I feel that I am not following the right approach to solve them

koteshmeesala
Автор

how do you get c++ to allow 3 parameters for max()?

danielmcgee
Автор

Thank you for the explanation. I wonder who comes up with these ingenious solutions of remembering the minimum numbers to make sure not to lose track of the overall product with negatives along with the max counter lol.

Kidkromechan
Автор

In the same problem, how can we find that SubArray?

rahulchudasama
Автор

Watched 3 videos before I got to yours and finally understood it! Thank you!

feraligatrs
Автор

Excellent and crisp explanation. Keep up the good work.

xinlee
Автор

I must say great video and great explination. It honestly deserves more views I encourage you too make more videos. Your channel will definity grow

ujjvalsharma
Автор

Here is my solution -- very similar to yours. Thanks!

def kadanesMaxProduct(array):
maxOverall, minEndingHere, maxEndingHere = 0, 0, 0
for i in array:
tmp = maxEndingHere
maxEndingHere = max(i, maxEndingHere * i, minEndingHere * i)
minEndingHere = min(i, tmp * i, minEndingHere * i)
maxOverall = max(maxOverall, maxEndingHere)
return maxOverall

jimwoodward
Автор

Can this be considered dynamic programming?

ChristianESL
Автор

I am python user, can cracking the coding interview book useful to me. Because it has written in java

venkatarakesh
Автор

if our max so far is -10 and min so far is -2 and A[i] is also -ve then this approach will work?

ankushroy
Автор

I understood how to do it just by watching till 15th min. Nice.

shalomalexander
Автор

I wanna know your IDE
Did you use this often ?
Recommend me the best one plz

dhananjaygola
Автор

At 08:46 you're saying that "if min_ending was positive then multiply it with the max ending - so whatever was the max_ending and if that is positive multiply it. That will become further positive. So that will be the max". Based on this I am expecting to see something like

min_ending=max(min_ending*max_ending, A[i])

in your solution but you end up writing something completely different. Is there any chance you can provide the exhaustive if condition before simplifying it into this 3 liner function?

nikostrongioglou
Автор

Nice explanation sir...really good video

paragroy
Автор

Great explanation bro, , keep making such good videos

anshulcse
Автор

is python not allowed in coding interviews?

inspired_enough_to_grow_up
Автор

your voice is like " Amitabh bacchan " 😂😂

tekbssync
Автор

i don't see zero case being handled here in the code

shishirpandey