You are given an array of distinct strings words.
For each word w in words, find a non-empty contiguous substring of w that does not appear as a substring in any other word in the array.
Return, for every word, the shortest such substring.
If a word has multiple valid substrings with the same minimal length:
You may assume that for every word, at least one such substring exists.
Input:
['cheapair', 'cheapoair', 'peloton', 'pelican']
Output:
{
'cheapair': 'pa',
'cheapoair': 'po',
'peloton': 't',
'pelican': 'li'
}
1 <= len(words) <= 2e3
1 <= len(words[i]) <= 2e3
<= 2e4