Problem 3093 · Hard

Longest Common Suffix Queries

Store the reversed container words in a trie, and keep at each node the shortest word (earliest on a tie) passing through it.

Open the interactive visualisation