Longest Palindromic Substring using dynamic programming : step by step with intuition

preview_player
Показать описание
Before watching this video do keep one thing in mind, never confuse longest common substring with longest common subsequence.
Both are different. Well the basic difference lies in the meaning of both.

1. Substring is a sequence of characters which are contiguous
2. Subsequence is also a sequence of characters which may be or may not be contiguous.

This means that a subsequence can be a substring but a substring can't be a subsequence.

In this video, I am going to teach you to solve longest palindromic substring using dynamic programming.
So, I did a video in which I told you about how to develop an intuition(link below) to come up with the solution of longest palindromic subsequence.

Well, the work on developing the intuition when it comes to longest palindromic substring is more or less the same but the difference lies in the approach.
Your approach can automatically be changed when you're going to give enough emphasis on the word substring.

Another thing which can greatly help you is go by the method using which we solved longest palindromic subsequence (link below) and apply the same in solving
the longest palindromic substring, you will come to know what I am talking about. Use this string 'dabcba'

After you have done the task and I am sure you're going to figure out where you're going wrong with the older method then only thing you have to do
is while constructing the dynamic programming algorithm at each subproblem you have to ask 'Is this a palindrome?'

If a subproblem is a palindrome then you're going to mention true there but if it is not then you have to mention it as false. Complete the matrix and then
it will tell you how to find out the length of the longest palindromic substring.

connection between different dynamic programming problems is the key to develop the intuition to solve DP problems.

So, with all the information with you let's watch this exciting video of Joey's dynamic programming tutorial series.
Рекомендации по теме
Комментарии
Автор

Another fantastic video. Complex concepts explained simply. That is a hard feat to manage but Joeys tech does it so beautifully every single time. Thank you Joeys' Tech for another great video

kattazann
Автор

Beautifully explained... keep uploading... 🙏

negideepak
Автор

You change my dynamic programming thinking to the next level. thank you so much. another fantastic video .. please keep it up.

ahsanamin
Автор

Not working for:
Input: s = "cbbd"
Output: "bb"

debmalyapan
Автор

It would be better if you explain brute force recursive solution first rather than dive into tabulation. Beginners won't get what that matrix does..

samrat_malisetti
visit shbcf.ru