Problem 3045 · Hard

Count Prefix and Suffix Pairs II

Index each word by its pairs of front and back letters in a trie, so prefix-and-suffix matches are found along one path.

Open the interactive visualisation