Welcome to Joey’sTech. In this video, you will learn to solve another interesting problem from the Leetcode website - ‘Maximum product Subarray’.
When I first came across this problem, I made a huge mistake by changing only the + sign in the code of the Maximum sum subarray problem without giving a thought to the term product.
I learned a lesson never to take any question statement for granted and go in-depth. I want to share my experience with you also.
Let’s move now to check out the problem statement of the maximum product subarray problem but before that I want you to subscribe to my channel and hit the bell icon because that way you’re going to get notified when I release new videos in the future.
You are given an array of both positive and negative integers.
The job is to find out the contiguous subarray that gives us the maximum product and also the maximum product that we are talking about.
Remember, you need to find a subarray not a subsequence, a subarray is made of contiguous elements from the array.
So, let’s do this now -
Take a good look at this problem array.
6, -3, -10, 0 ,2
The array is filled with positive and negative integers.
While adding, a positive integer with a negative one, the result will be negative. While adding two negative integers the result will again be negative.
However, that’s not the case while doing the product of two negative integers.
Multiplying two negative integers will lead to a positive integer.
How about you see my explanation in the video?
Below is the GitHub link to the java solution-
https://github.com/joeystech2020/dyna...
On this page of the site you can watch the video online Maximum Product Subarray using dynamic programming | Leetcode with a duration of hours minute second in good quality, which was uploaded by the user Joey'sTech 29 June 2021, share the link with friends and acquaintances, this video has already been watched 876 times on youtube and it was liked by 15 viewers. Enjoy your viewing!