Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Handle null input explicitly in Lyndon factorization
  • Loading branch information
vedant0517 committed Oct 9, 2026
commit 5626d97f026960bd08403f88ac2eb94ad8d49e10
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
* Factorizes a string into its Lyndon words using Duval's algorithm.
Expand All @@ -25,10 +24,12 @@ private LyndonFactorization() {
*
* @param text input string to factorize
* @return Lyndon factors in non-increasing lexicographic order
* @throws NullPointerException if {@code text} is null
* @throws IllegalArgumentException if {@code text} is null
*/
public static List<String> factorize(String text) {
Objects.requireNonNull(text, "text must not be null");
if (text == null) {
throw new IllegalArgumentException("text must not be null");
}

List<String> factors = new ArrayList<>();
int n = text.length();
Expand Down
Loading