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