Palindromic Substrings - Leetcode 647 - Python

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


0:00 - Read the problem
2:54 - Drawing Explanation
11:25 - Coding Explanation

leetcode 647

#palindromic #substrings#python
Disclosure: Some of the links above may be affiliate links, from which I may earn a small commission.
Рекомендации по теме
Комментарии
Автор

My day is incomplete without listening this:
"Hey everyone, welcome back! and let's write some more neat code today".

jonaskhanwald
Автор

Currently completed around 40% of the BLIND list. Thanks neetcode for always very clear explaination!

seungjunlee
Автор

14:06
what i did with 108 lines of code in cpp, he did in 16 lines of code in python

IslamWaleed-ggmc
Автор

Shorter solution that I found

class Solution:
def countSubstrings(self, s: str) -> int:

res = 0

def pl(l, r) -> int:
if l < 0 or r > len(s) - 1:
return 0
if s[l] == s[r]:
return 1 + pl(l - 1, r + 1)
return 0

for i in range(len(s)):
res += pl(i, i) + pl(i, i+1)

return res

drstoneftw
Автор

I owe you one for making this concept so simple and crystal!

srinadhp
Автор

Top tier resource as I study algos for upcoming Google interview <3

shoooozzzz
Автор

Bro dont stop posting videos, I will try to donate weekly for coffee and share link to atleast one person to support ur videos.

richard
Автор

Took help to understand the longest palindromic substring, but was able to solve this by myself. All thanks to the great way of teaching! Hats off man! I am a data scientist, who hadn't touched DSA for so long. But your 150 series has helped me a lot. I have my Google interview on 31st Jan. I don't know what will happen that day, but I'm pretty sure my DSA is way better than what it was a month ago.

RaviPrakash-dzfm
Автор

The best explanation on palindromic substrings so far! Thanks a ton!

nehascorpion
Автор

After watching longest palindromic substring neetcode video came up with this:

class Solution:
def countSubstrings(self, s: str) -> int:
res = 0

def check(l, r):
nonlocal res

while l>= 0 and r < len(s) and s[l] == s[r]:
res += 1
l -= 1
r += 1



for i in range(len(s)):
check(i, i)
check(i, i+1)

return res

hwang
Автор

loving blind 75 series, learning a lot

BigFishMachine
Автор

Keep making videos bro, you’re really good! thank you so much!

dnm
Автор

The clearest explanation all over the Internet

kirillzlobin
Автор

What a smart solution! I see this question is categorized as a DP problem on LC and was struggling of thinking to solve in a DP way. Really like the way you explain a question and find a much simpler way to solve it!

americandream
Автор

You can also use Manacher's algorithm for O(n) and O(n) time space complexity!

enkr
Автор

I was able to solve this today by myself because i'd seen you do it a couple of months back. Thanks for everything man!

zaki_
Автор

Great explanation but not sure why this is categorized as dp on your website

Same solution as longest palindrome problem (for each index expand outwards to find palindromes)

mostinho
Автор

Beautiful and clean solution. Thank you. And I love your clean coding style!

johnnychang
Автор

thank you so much neetcode. It is such a relief that when i am stuck i know i can rely on you to help me out and understand something

anusha
Автор

Terrific explanation. So well explained.

MP-nyep
welcome to shbcf.ru