Grokking Dynamic Programming Patterns for Coding Interviews
Vote

0% completed

​

Count of Palindromic Substrings

.....

.....

.....

Like the course? Get enrolled and start learning!
A

Anonymous

· 2 years ago

class Solution: def findCPS(self, st): def is_palindrom(s, i, j): while i <= j : if s[i] != s[j]: return False i += 1 j -= 1 return True count = 0 for i in range(0, len(st)): for j in range(i, len(st)): if is_palindrom(st, i, j): count += 1 return count
A

Anonymous

· 4 years ago

Can you add the brute force, swapping the max for count does not work on the leetcode problem

Show 2 replies

Reading Progress

0%


Vote for new content