FPEvalRepoPublic/LeetCodeMetaData
0399
1{2 "id": 3356,3 "name": "shortest-uncommon-substring-in-an-array",4 "difficulty": "Medium",5 "link": "https://leetcode.com/problems/shortest-uncommon-substring-in-an-array/",6 "date": "2024-03-03",7 "task_description": "You are given an array `arr` of size `n` consisting of **non-empty** strings. Find a string array `answer` of size `n` such that: `answer[i]` is the **shortest** substring of `arr[i]` that does **not** occur as a substring in any other string in `arr`. If multiple such substrings exist, `answer[i]` should be the lexicographically smallest. And if no such substring exists, `answer[i]` should be an empty string. Return _the array _`answer`. **Example 1:** ``` **Input:** arr = [\"cab\",\"ad\",\"bad\",\"c\"] **Output:** [\"ab\",\"\",\"ba\",\"\"] **Explanation:** We have the following: - For the string \"cab\", the shortest substring that does not occur in any other string is either \"ca\" or \"ab\", we choose the lexicographically smaller substring, which is \"ab\". - For the string \"ad\", there is no substring that does not occur in any other string. - For the string \"bad\", the shortest substring that does not occur in any other string is \"ba\". - For the string \"c\", there is no substring that does not occur in any other string. ``` **Example 2:** ``` **Input:** arr = [\"abc\",\"bcd\",\"abcd\"] **Output:** [\"\",\"\",\"abcd\"] **Explanation:** We have the following: - For the string \"abc\", there is no substring that does not occur in any other string. - For the string \"bcd\", there is no substring that does not occur in any other string. - For the string \"abcd\", the shortest substring that does not occur in any other string is \"abcd\". ``` **Constraints:** `n == arr.length` `2 <= n <= 100` `1 <= arr[i].length <= 20` `arr[i]` consists only of lowercase English letters.",8 "test_case": [9 {10 "label": "Example 1",11 "input": "arr = [\"cab\",\"ad\",\"bad\",\"c\"]",12 "output": "[\"ab\",\"\",\"ba\",\"\"] "13 },14 {15 "label": "Example 2",16 "input": "arr = [\"abc\",\"bcd\",\"abcd\"]",17 "output": "[\"\",\"\",\"abcd\"] "18 }19 ],20 "constraints": [21 "answer[i] is the shortest substring of arr[i] that does not occur as a substring in any other string in arr. If multiple such substrings exist, answer[i] should be the lexicographically smallest. And if no such substring exists, answer[i] should be an empty string.",22 "n == arr.length",23 "2 <= n <= 100",24 "1 <= arr[i].length <= 20",25 "arr[i] consists only of lowercase English letters."26 ],27 "python_template": "class Solution(object):\n def shortestSubstrings(self, arr):\n \"\"\"\n :type arr: List[str]\n :rtype: List[str]\n \"\"\"\n ",28 "java_template": "class Solution {\n public String[] shortestSubstrings(String[] arr) {\n \n }\n}",29 "metadata": {30 "func_name": "shortestSubstrings"31 }32}