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