Given an array of string words. Return all strings in words which is substring of another word in any order.
String words[i] is substring of words[j], if can be obtained removing some characters to left and/or right side of words[j].
Constraints:
- 1 <= words.length <= 100
- 1 <= words[i].length <= 30
- words[i] contains only lowercase English letters.
- It's guaranteed that words[i] will be unique.
給一個字串陣列words。以任何排序回傳所有在words中,是其他任意字串的子字串的字串。
如果words[i]在右邊或左邊加入任意字元後可以變成words[j],字串words[i]是words[j]的子字串。
限制:
- 1 <= words.length <= 100
- 1 <= words[i].length <= 30
- words[i] 只包含小寫英文字母。
- 保證words[i]的獨特性(不會重複)。
find()
的功能,可以直接使用。
unique()
將最後答案移除重複的元素。LeetCode
C++