You are viewing a single comment's thread. Return to all comments →
public class Solution {
public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String test = scanner.nextLine(); int tests = scanner.nextInt(); System.out.println(getSmallestAndLargest(test, tests)); } public static String getSmallestAndLargest(String s, int l){ List<String> res = new ArrayList<>(); int condition = s.length() - l; for (int i = 0; i <= condition; i++) { String temp = s; String c = s.substring(0 , l); res.add(c); s = temp.substring(1); } Collections.sort(res); return res.get(0) + "\n" + res.get(res.size() - 1); }
}
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 →
public class Solution {
}