labels. For each string labels[i], find its shortest substring (a contiguous piece) that does **not occur** in any other string of the list.
If several such substrings share the minimal length, take the lexicographically smallest one. If no such substring exists at all, the answer for that string is an empty string.
Return the list of answers, one per string, in the same order as labels.labels=["milk", "silk", "mint"] → ['mil', 's', 'n']
Every single letter of "milk" appears elsewhere, and so do "mi", "il" and "lk"; "mil" is the shortest piece only it has. "silk" has the unique letter "s". "mint" has "n" and "t", and "n" comes first.
labels=["ab", "abc"] → ['', 'c']
Everything in "ab" also appears in "abc", so its answer is empty. "abc" owns the letter "c".
labels=["aa", "aa"] → ['', '']
The two labels are identical, so neither has a piece of its own.
labels=["milk", "silk", "mint"]
['mil', 's', 'n']
Run checks the first 3 tests in your browser. Submit checks all 112 tests on the server, hidden ones included.