Maximum Product Subarray using dynamic programming | Leetcode

Опубликовано: 29 Июнь 2021
на канале: Joey'sTech
876
15

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...


На этой странице сайта вы можете посмотреть видео онлайн Maximum Product Subarray using dynamic programming | Leetcode длительностью часов минут секунд в хорошем качестве, которое загрузил пользователь Joey'sTech 29 Июнь 2021, поделитесь ссылкой с друзьями и знакомыми, на youtube это видео уже посмотрели 876 раз и оно понравилось 15 зрителям. Приятного просмотра!