Count the Number of Consistent Strings LeetCode solution in Java
1class Solution {2public int countConsistentStrings(String allowed, String[] words) {3Set<Character> allowedSet = new HashSet<>();4for (int i = 0; i < allowed.length(); i++) {5allowedSet.add(allowed.charAt(i));6}78int count = 0;9for (String word : words) {10if (isConsistent(allowedSet, word)) count++;11}1213return count;14}1516boolean isConsistent(Set<Character> allowedSet, String word) {17for (int i = 0; i < word.length(); i++) {18if (!allowedSet.contains(word.charAt(i))) return false;19}20return true;21}22}