Search
⌘K
Get Premium
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.
All Regions
Comments
Hello Interview Premium
Your account is free and you can post anonymously if you choose.