image_2021-10-15_23-44-42.png
47.2 KB
#N1684 Count the Number of Consistent Strings
problem link=>https://leetcode.com/problems/count-the-number-of-consistent-strings/
#solution
problem link=>https://leetcode.com/problems/count-the-number-of-consistent-strings/
#solution
class Solution {
public int countConsistentStrings(String allowed, String[] words) {
int count = 0;
for (String s : words) {
boolean isValid = true;
for (char ch : s.toCharArray()) {
if (!allowed.contains(String.valueOf(ch))) {
isValid = false;
}
}
if (isValid) count++;
}
return count;
}
}