-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNews_Cluster.java
More file actions
42 lines (32 loc) · 1 KB
/
News_Cluster.java
File metadata and controls
42 lines (32 loc) · 1 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
package programmers_newscluster;
import java.util.*;
import java.lang.*;
public class News_Cluster {
public static int solution(String str1, String str2) {
int answer = 1;
str1 = str1.toUpperCase();
str2 = str2.toUpperCase();
String[] str_arr1 = new String[str1.length() - 1];
String[] str_arr2 = new String[str2.length() - 1];
for (int i = 0; i < str1.length() - 1; i++) {
char c1 = str1.charAt(i);
char c2 = str1.charAt(i + 1);
if (c1 > 'Z' || c1 < 'A' || c2 > 'Z' || c2 < 'A') {
continue;
}
str_arr1[i] = str1.substring(i, i + 2);
}
for (int i = 0; i < str2.length() - 1; i++) {
char c1 = str2.charAt(i);
char c2 = str2.charAt(i + 1);
if (c1 > 'Z' || c1 < 'A' || c2 > 'Z' || c2 < 'A') {
continue;
}
str_arr2[i] = str2.substring(i, i + 2);
}
return answer;
}
public static void main(String[] args) {
solution("FRANCE", "french");
}
}