Interval Dynamic Programming: Classic Problems and Solutions

Progress: Dynamic Programming - Linear DP, Knapsack, Interval DP Merging Palindromic Substrings Tags: Interval DP Foundation - Longest Palindromic Substring Problem: Given a string (S), find the length of its longest palindromic substring. Approach: A longer palindrome can always be constructed by adding identical characters to both ends of a s ...

Posted on Thu, 14 May 2026 05:56:34 +0000 by sb

Essential String Algorithms and Techniques

Longest Common PrefixApproach 1: Pairwise Comparison - Time Complexity O(m*n)class CommonPrefixFinder { public: string findLongestCommonPrefix(vector<string>& words) { // Pairwise comparison string result = words[0]; size_t count = words.size(); for(size_t i = 0; i < count; ++i) result = find ...

Posted on Sun, 10 May 2026 11:15:20 +0000 by Phasma Felis

Suffix Automaton: Definition, Construction, and Applications

Definition A suffix automaton (SAM) for a string (s) is the minimal deterministic finite automaton (DFA) that accepts all suffixes of (s). Formally: A SAM is a directed acyclic graph (DAG) where nodes represent states and edges represent transitions. The source node (t_0) serves as the initial state. All states are reachable from (t_0). Each t ...

Posted on Fri, 08 May 2026 15:39:54 +0000 by james13009