-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprblm1935.java
More file actions
31 lines (28 loc) · 878 Bytes
/
prblm1935.java
File metadata and controls
31 lines (28 loc) · 878 Bytes
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
import java.util.*;
public class prblm1935 {
public static void main(String[] args) {
String text = "hello world", brokenLetters = "ad";
System.out.println(new prblm1935().canBeTypedWords(text, brokenLetters));
}
public int canBeTypedWords(String text, String brokenLetters) {
Set<Character> set = new HashSet<>();
for (char ch : brokenLetters.toCharArray()) {
set.add(ch);
}
int ans = 0;
String[] arr = text.split(" ");
for (String str : arr) {
boolean canTyped = true;
for (char ch : str.toCharArray()) {
if (set.contains(ch)) {
canTyped = false;
break;
}
}
if (canTyped) {
ans++;
}
}
return ans;
}
}