Search
⌘K

Leetcode 3045. Count Prefix and Suffix Pairs II

Count pairs (i < j) where words[i] is both a prefix and a suffix of words[j]. With up to 5e5 total characters, the challenge is to avoid quadratic pairwise checks and use efficient string-matching or grouping by word/length (e.g., hashing/trie/KMP) to count matches.


Question Timeline

See when this question was last asked and where, including any notes left by other candidates.

Comments

Your account is free and you can post anonymously if you choose.