Find all concatenations of two string in a huge set
问题 Given a set of 50k strings, I need to find all pairs (s, t) , such that s , t and s + t are all contained in this set. What I've tried , there's an additional constraint: s.length() >= 4 && t.length() >= 4 . This makes it possible to group the strings by length 4 prefixes and, separately, suffixes. Then for every string composed of length at least 8, I look up the set of candidates for s using the first four characters of composed and the set of candidates for t using its last four characters