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