← 返回 meta 的题目列表Character Subset
类型:online_judge
Given an array of strings, find all the strings that can be represented by a subset of characters from the alphabet. A character subset means the string must be composed from a specific set of characters.
Input:
An array of strings words.
A set of characters subset.
Output:
Return an array of strings that can be composed from the characters in subset.
Example:
Input: words = ["apple", "banana", "cherry"], subset = ['a', 'p', 'l', 'e']
Output: ["apple"]
Input: words = ["apple", "banana", "cherry"], subset = ['c', 'h', 'e', 'r', 'y']
Output: ["cherry"]
Constraints:
The length of the string array is no more than 1000.
Each string has a maximum length of 100.
The character subset has a maximum of 26 characters.
Example
Input
['apple', 'banana', 'cherry'] ['a', 'p', 'l', 'e']