You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE REQUEST] Add Duval's algorithm for Lyndon factorization #7638
I would like to contribute Duval's algorithm for Lyndon factorization in the com.thealgorithms.strings package. I did not find a Lyndon factorization
implementation in the current source tree or DIRECTORY.md.
Proposed API: LyndonFactorization.factorize(String text) returning List<String> in non-increasing lexicographic order, using Java's UTF-16
code-unit ordering.
Examples:
banana -> [b, an, an, a]
ababab -> [ab, ab, ab]
empty input -> []
null input -> NullPointerException
The implementation uses O(n) time and O(1) working space excluding the returned
factors. Tests include an independent check of the Lyndon-word and ordering
properties for every short string over a three-character alphabet.
The code and tests have been prepared with AI assistance. Before submitting a
PR, could you confirm whether this addition and assistance disclosure are
acceptable, including how to handle the PR template's "all my own work" item?
Activity