Description
Given a string allowed and an array of strings words, return the number of consistent strings. A string is consistent if all characters appear in allowed.
Examples
Input:
allowed = "ab", words = ["ad","bd","aaab","baa","badab"]Output:
2Explanation:
Only aaab and baa are consistent.
Input:
allowed = "cad", words = ["cc","acd","b","ba","bac","bad","ac","d"]Output:
4Explanation:
Checking each word: "cc" (valid), "acd" (valid), "b" (invalid - 'b' not allowed), "ba" (invalid), "bac" (invalid), "bad" (invalid), "ac" (valid), "d" (valid). 4 strings are consistent.
Input:
allowed = "xyz", words = ["x","y","z","xy","xz","yz","xyz","xyza"]Output:
7Explanation:
All words are consistent except "xyza" because it contains 'a' which is not in the allowed string "xyz". The first 7 words only use combinations of the allowed characters 'x', 'y', and 'z'.
Constraints
- •
1 ≤ words.length ≤ 10^4