Understanding the top down solution to the longest palindromic substring problem


To solve the longest palindromic substring problem using a top-down dynamic programming approach, we translate the recurrence relation into recursive functions and use memoization tables to store results of subproblems that have already been solved.

The top down solution

As with any top-down solution, there are recursive functions that solve subproblems and a calling function that initializes the required data structures and triggers the computation. However, the recurrence relation for the longest palindromic substring has two parts where one relies on the result from the other, and so we define two recursive functions that work together to solve the problem.

Liking the course? Check our discounted plans to continue learning.