-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPMS_64064.java
More file actions
53 lines (41 loc) · 1.41 KB
/
PMS_64064.java
File metadata and controls
53 lines (41 loc) · 1.41 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
49
50
51
52
53
package programmers;
import java.util.ArrayList;
import java.util.List;
public class PMS_64064 {
public int solution(String[] user_id, String[] banned_id) {
int answer = 0;
ArrayList<List<String>> lists = new ArrayList<>();
for (int i = 0; i < banned_id.length; i++) {
List<String> possibleNames = findPossibleName(banned_id[i], user_id);
lists.add(possibleNames);
}
return answer;
}
public static List<String> findPossibleName(String targetId, String[] user_id) {
ArrayList<String> possibleNames = new ArrayList<>();
String[] targetWords = targetId.split("");
for (String user : user_id) {
if (targetId.length() != user.length()) {
continue;
}
for (int i = 0; i < targetWords.length; i++) {
if (isPossible(targetWords, user)) {
possibleNames.add(user);
}
}
}
return possibleNames;
}
public static boolean isPossible(String[] targetWords, String userName) {
String[] userWords = userName.split("");
for (int i = 0; i < targetWords.length; i++) {
if (targetWords[i].equals("*")) {
continue;
}
if (!userWords[i].equals(targetWords[i])) {
return false;
}
}
return true;
}
}