The problem statement is:
Given a list of strings, find the shortest unique substring of each string such that the substring does not occur in any of the other strings.
For example:
Input: ["cheapair", "cheapoair", "peloton", "pelican"]
Output:
"cheapair": "pa" // every other 1-2 length substring overlaps with cheapoair
"cheapoair": "po" // "oa" would also be acceptable
"pelican": "ca" // "li", "ic", or "an" would also be acceptable
"peloton": "t" // this single letter doesn't occur in any other string
I think this is solved with dynamic programming, but honestly, I have no idea how to do this other than brute force: Storing all substrings for each word and checking that they don't exist in any of the other ones, which is a terrible idea.
["abab", "ba"]?