We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
public static void main(String[] args) {
/* Enter your code here. Read input from STDIN. Print output to STDOUT. Your class should be named Solution. */
Scanner sc=new Scanner(System.in);
String st=sc.next();
int k=sc.nextInt();
ArrayList<String> sub1=new ArrayList<>();
for(int i=0;i<=st.length()-k;i++)
{
sub1.add(st.substring(i,i+k));
}
Collections.sort(sub1);
System.out.println(sub1.get(0));
System.out.println(sub1.get(sub1.size()-1));
}
}
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Java Substring Comparisons
You are viewing a single comment's thread. Return to all comments →
import java.io.; import java.util.;
public class Solution {
}