Back to problems

Longest Palindromic Subsequence

Algorithm · Microsoft · Hard

For a given string s, determine the size of its longest subsequence that reads identically from left to right and right to left. The length of s will not exceed 1000. Input Specification Input contains only lowercase letters from the English alphabet. The input is the string s. Output Specification Output the length of the longest palindromic subsequence in s. Test Cases Input: s = 'abca', Output: 3 (One longest palindromic subsequence is 'aba'.) Input: s = 'aebcbda',…

Checking your access…