← 返回 meta 的题目列表Shortest Prefix
类型:online_judge
Given a list of strings strs, find a unique shortest prefix for each of the strings. Return a list of these prefixes.
Example
Input: strs = ["dog", "cat", "apple", "apricot", "fish"]
Output: ["d", "c", "app", "apr", "f"]
Constraints
1 <= strs.length <= 1000
1 <= strs[i].length <= 100
strs[i] consists of lowercase letters only
Requirement
Provide a method with the lowest possible time complexity.
Example
Input
dog
cat
apple
apricot
fish