Leetcode in Java && Oracle
421 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
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
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;
}
}