Competitive-Programming-and-Contests-VP-Solution

The repository that contains all solutions made for the course Competitive Programming and Contests by the University of Pisa

View the Project on GitHub

Longest Palindromic Subsequence

Solved Solution Time :clock11:
:heavy_check_mark: Dynamic Programming (O(N^2)) TLE
:heavy_checl_mark: Dynamic Programming (O(N)) 56 ms

Solution or Solution discussion

Dynamic Programming O(n^2)

The solution with dynamic programming proposed in this section use the recursion to find the result of the problme, and the recusion look like

Dynamic Programming O(N) exstra space (With memorizzation)

To improve the solution we ca use a bottom up solution with the memorization technique based on the previus recursion, that save time complexity of the algorithm. It solution reduce the space complexity from O(N^2) to O(N) and it store the result inside an array.

The solution of the problem is in the last position of the array.