2023-12-09 18:42:21 +08:00
< p > Given an array of string < code > words< / code > , return < em > all strings in < / em > < code > words< / code > < em > that is a < strong > substring< / strong > of another word< / em > . You can return the answer in < strong > any order< / strong > .< / p >
2022-03-27 20:37:52 +08:00
2023-12-09 18:42:21 +08:00
< p > A < strong > substring< / strong > is a contiguous sequence of characters within a string< / p >
2022-03-27 20:37:52 +08:00
< p > < / p >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 1:< / strong > < / p >
2022-03-27 20:37:52 +08:00
< pre >
< strong > Input:< / strong > words = [" mass" ," as" ," hero" ," superhero" ]
< strong > Output:< / strong > [" as" ," hero" ]
< strong > Explanation:< / strong > " as" is substring of " mass" and " hero" is substring of " superhero" .
[" hero" ," as" ] is also a valid answer.
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 2:< / strong > < / p >
2022-03-27 20:37:52 +08:00
< pre >
< strong > Input:< / strong > words = [" leetcode" ," et" ," code" ]
< strong > Output:< / strong > [" et" ," code" ]
< strong > Explanation:< / strong > " et" , " code" are substring of " leetcode" .
< / pre >
2023-12-09 18:42:21 +08:00
< p > < strong class = "example" > Example 3:< / strong > < / p >
2022-03-27 20:37:52 +08:00
< pre >
< strong > Input:< / strong > words = [" blue" ," green" ," bu" ]
< strong > Output:< / strong > []
2023-12-09 18:42:21 +08:00
< strong > Explanation:< / strong > No string of words is substring of another string.
2022-03-27 20:37:52 +08:00
< / pre >
< p > < / p >
< p > < strong > Constraints:< / strong > < / p >
< ul >
< li > < code > 1 < = words.length < = 100< / code > < / li >
< li > < code > 1 < = words[i].length < = 30< / code > < / li >
< li > < code > words[i]< / code > contains only lowercase English letters.< / li >
2023-12-09 18:42:21 +08:00
< li > All the strings of < code > words< / code > are < strong > unique< / strong > .< / li >
2022-03-27 20:37:52 +08:00
< / ul >