Count Prefix and Suffix Pairs

Easy · Trie · about 15 minutes

Asked at Google, Amazon, Microsoft.

Return the number of index pairs i < j such that words[i] is both a prefix and a suffix of words[j].

Related guides