Computing Longest Lyndon Subsequences and Longest Common Lyndon Subsequences
Hideo Bannai, I Tomohiro, Tomasz Kociumaka, Dominik Köppl, Simon J. Puglisi · Algorithmica · 2023
Abstract Given a string T of length n whose characters are drawn from an ordered alphabet of size $$\sigma $$ σ , its longest Lyndon subsequence is a maximum-length subsequence of T that is a Lyndon word. We propose algorithms for finding such a subsequence in $$\mathop {}\mathopen {}\mathcal {O}\mathopen {}(n^3)$$ O ( n 3 ) time with $$\mathop {}\mathopen {}\mathcal {O}\mathopen {}(n)$$ O ( n ) space, or online in $$\mathop {}\mathopen {}\mathcal {O}\mathopen {}(n^3)$$ O ( n 3 ) space and time. Our first result can be extended to find the longest common Lyndon subsequence of two strings of length at most n in $$\mathop {}\mathopen {}\mathcal {O}\mathopen {}(n^4 \sigma )$$ O ( n 4 σ ) time using $$\mathop {}\mathopen {}\mathcal {O}\mathopen {}(n^2)$$ O ( n 2 ) space.