data-structures · intermediate · ~15 min
Find the longest palindromic subsequence length.
Implement:
int lps(const char *s);
Return the length of the Longest Palindromic Subsequence of s.
A string.
LPS length.
Interval DP over substrings (i..j).
#include <stddef.h>
/* Length of the Longest Palindromic Subsequence of s. */
int lps(const char *s){ (void)s; return 0; }
Iterating in the wrong order — inner substrings must be solved before outer ones.
Single char -> 1; empty -> 0.
Solve this exercise in the browser editor — compile and run against the test harness, no setup required.