-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathSubstring.java
61 lines (40 loc) · 1.09 KB
/
Substring.java
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
54
55
56
57
58
59
60
61
/*
Given a string, , and two indices, start and end, print a substring consisting of all characters in the inclusive range from start to
end-1
. You'll find the String class' substring method helpful in completing this challenge.
Input Format
The first line contains a single string denoting
.
The second line contains two space-separated integers denoting the respective values of and
.
Constraints
String consists of English alphabetic letters (i.e.,[a-zA-Z]
) only.
Output Format
Print the substring in the inclusive range from start
to end-1
.
Sample Input
Helloworld
3 7
Sample Output
lowo
Explanation
In the diagram below, the substring is highlighted in green:
substring.png
*/
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;
public class Solution {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
String S = in.next();
int start = in.nextInt();
int end = in.nextInt();
String sub_s=S.substring(start,end);
System.out.println(sub_s);
}
}