-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsistentStrings.java
More file actions
48 lines (44 loc) · 1.27 KB
/
ConsistentStrings.java
File metadata and controls
48 lines (44 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
<<<<<<< HEAD
//1684. Count the Number of Consistent Strings
class Solution {
public int countConsistentStrings(String allowed, String[] words) {
boolean[] isAllowed = new boolean[26];
for(char c : allowed.toCharArray()){
isAllowed[c - 'a'] = true;
}
int count = 0;
for(String word : words){
boolean flag = true;
for(char c : word.toCharArray()){
if(!isAllowed[c - 'a']){
flag = false;
break;
}
}
if(flag) count++;
}
return count;
}
=======
//1684. Count the Number of Consistent Strings
class Solution {
public int countConsistentStrings(String allowed, String[] words) {
boolean[] isAllowed = new boolean[26];
for(char c : allowed.toCharArray()){
isAllowed[c - 'a'] = true;
}
int count = 0;
for(String word : words){
boolean flag = true;
for(char c : word.toCharArray()){
if(!isAllowed[c - 'a']){
flag = false;
break;
}
}
if(flag) count++;
}
return count;
}
>>>>>>> be6ce0b427078b1421d5dd74adb2300dc02daeec
}