hacker rank 15th problem solution(java substring)
15.java Substring
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();
String substr="";
int start = in.nextInt();
int end = in.nextInt();
substr = S.substring(start, end);
System.out.println(substr);
}
}
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();
String substr="";
int start = in.nextInt();
int end = in.nextInt();
substr = S.substring(start, end);
System.out.println(substr);
}
}
Comments