You are a content moderator for a social media platform, and you need to validate user posts based on allowed characters. You have been given a string of allowed characters and an array of user-generated strings that need to be checked.
A string is considered consistent if all characters in the string appear in the allowed characters string. Your task is to count how many strings in the array are consistent.
Goal: Return the number of consistent strings in the array.
Example: If allowed characters are "abc" and we have words ["a", "b", "c", "ab", "ac", "bc", "abc", "xyz"], then 7 strings are consistent (all except "xyz" which contains characters not in the allowed set).
Input & Output
Constraints
- 1 โค words.length โค 104
- 1 โค allowed.length โค 26
- 1 โค words[i].length โค 10
- The characters in allowed are distinct
- allowed and words[i] consist of lowercase English letters only