Maximum Product Subarray | Leet code 152 | Theory explained + Python code

preview_player
Показать описание
This video is a solution to Leet code 152, Maximum Product Subarray. I explain the question and the best way to solve it and then solve it using Python.

Comment below if you have a better solution to this problem!

Let me know if you have any feedback and don't forget to subscribe for more videos!

Timestamps:
0:00 Question Explained
1:18 Solution Explained
9:46 Python Code

More leetcode questions solved:

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

Thanks for the great explanation and your accent of english speaking is good and different

sulemankhan
Автор

Hey Anish,
I have been following your videos for quite sometime now and I must say your way of explaining the solution is amazing. Just one piece of feedback, it would be great if you can discuss the time and space complexity as well.
Thank you so much.

birajparikh
Автор

what is the time and space complexity of this algorithm?

gopasprem
Автор

whats the x-1 here its next digit or the previous one

taran
Автор

What is the time complexity for this one? O(N^2)?

wannabeboxer
Автор

Can we modify the kadane's algorithm here?
heres my code, where am I wrong?:

def maxprosum(nums):
curpro=maxpro=nums[0]
for i in range(1, len(nums)-1):
curpro = max(nums[i], curpro*nums[i])
if maxpro<curpro:
maxpro=curpro

return maxpro

pythonenthusiast