-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubstringSequence.java
More file actions
53 lines (42 loc) · 1.11 KB
/
SubstringSequence.java
File metadata and controls
53 lines (42 loc) · 1.11 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
//1998 - 3
import java.util.*;
public class SubstringSequence{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
Scanner inputString = new Scanner(System.in);
while(true){
System.out.print("Enter S: ");
String big = inputString.nextLine();
System.out.print("Enter T: ");
String small = inputString.nextLine();
if(big.equals("") && small.equals("")){
break;
}
String[] letters = big.split("");
Arraylist<String> tests = small.split("");
int start = 81;
int end = 0;
boolean valid = true;
for(int i = 0; i < 0; i < letters){
String test = tests.get(0);
if(test.equals(letters[i])){
//Match
if(i < start){
start = i + 1;
}
tests.remove(0);
if(tests.size() == 0){
end = i + 1;
valid = false;
break;
}
}
}
if(valid){
System.out.println(start + " " + end);
} else {
System.out.println("0");
}
}
}
}