← ALL NOTES
Array

3042. Count Prefix and Suffix Pairs I

Given a string array words. A pair (i, j) with i < j is a prefix-and-suffix pair if words[i] is both a prefix and a suffix of words[j]. Count such pairs. Enumerate all pairs i < j and check the…

Loading…