Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
40 lines (39 loc) · 1.24 KB

File metadata and controls

40 lines (39 loc) · 1.24 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
public class Main1 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] str11 = br.readLine().trim().split(" ");
String str1 = str11[0];
String str2 = str11[1];
System.out.println(Main1.getCommonStrLength(str1,str2));
}
public static String getCommonStrLength(String str1, String str2){
if(str1 == null || str2 == null){
return null;
}
if (str1.equals("") || str2.equals("")){
return null;
}
String max = "";
String min = "";
if(str1.length() < str2.length()){
max = str2;
min = str1;
} else {
max = str1;
min = str2;
}
String current = "";
for(int i = 0; i < min.length(); i++){
for(int begin = 0, end = min.length(); end <= min.length(); begin++,end++){
current = min.substring(begin, end);
if(max.contains(current)){
return current;
}
}
}
return null;
}
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.