Practice Shortest Uncommon Substring in an Array
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
For each string arr[i], find the shortest nonempty substring that does not occur in any other string in arr. If several shortest substrings qualify, choose the lexicographically smallest. Use an empty string when none qualifies, and return the answers in the same order as arr.
Source: Shortest Uncommon Substring in an Array on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
Input
arr = ["cab","ad","bad","c"]
Output
["ab","","ba",""]
# Example 2
Input
arr = ["abc","bcd","abcd"]
Output
["","","abcd"]
Constraints
n == arr.length
2 <= n <= 100
1 <= arr[i].length <= 20
arr[i] consists only of lowercase English letters.
Related LeetCode Problems
Practice more problems similar to Shortest Uncommon Substring in an Array.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.