Skip to content

Commit 8b80547

Browse files
committed
Runtime: 15 ms (Top 73.10%) | Memory: 54.7 MB (Top 46.20%)
1 parent 47aabc6 commit 8b80547

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed
Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,23 @@
1+
// Runtime: 15 ms (Top 73.10%) | Memory: 54.7 MB (Top 46.20%)
12
class Solution {
23
public int countConsistentStrings(String allowed, String[] words) {
34
Set<Character> allowedSet = new HashSet<>();
45
for(int i=0;i<allowed.length();i++){
56
allowedSet.add(allowed.charAt(i));
67
}
7-
8+
89
int count = 0;
910
for(String word: words){
1011
if(isConsistent(allowedSet, word)) count++;
1112
}
12-
13+
1314
return count;
1415
}
15-
16+
1617
boolean isConsistent(Set<Character> allowedSet, String word){
1718
for (int i = 0; i < word.length(); i++){
18-
if(!allowedSet.contains(word.charAt(i))) return false;
19+
if(!allowedSet.contains(word.charAt(i))) return false;
1920
}
2021
return true;
2122
}
22-
}
23+
}

0 commit comments

Comments
 (0)