You are viewing a single comment's thread. Return to all comments →
public static String getSmallestAndLargest(String s, int k) {
String smallest = s.substring(0, k); String largest = s.substring(0, k); for (int i = 0; i < s.length()-k+1; i++) { String input = s.substring(i,k+i); if(input.compareTo(largest)>0){ largest=input; } if(input.compareTo(smallest)<0){ smallest=input; } } return smallest + "\n" + largest; }
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 static String getSmallestAndLargest(String s, int k) {