Brute Force Approach

The brute-force approach is to find all possible subsequences of the given string and check if they are valid palindromes. From these palindromic subsequences, we want the subsequence with the longest length.

Brute Force Approach

However, this approach is not an ideal one. Why? Because it can go up to exponential time complexity for longer strings. Can you think of a better, more efficient solution to this problem?