MCPcopy Create free account
hub / github.com/Tiwarishashwat/InterviewCodes / Solution

Class Solution

CountTheNumberOfConsistentStrings.java:1–23  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1class Solution {
2 public int countConsistentStrings(String allowed, String[] words) {
3 int counter=0;
4 HashSet<Character> set = new HashSet<Character>();
5 for(int i=0;i<allowed.length();i++)
6 {
7 set.add(allowed.charAt(i));
8 }
9 for(String str: words)
10 {
11 boolean flag=true;
12 for(int i=0;i<str.length();i++)
13 {
14 if(!set.contains(str.charAt(i)))
15 {
16 flag=false;
17 }
18 }
19 if(flag) counter++;
20 }
21 return counter;
22 }
23}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected