You are viewing a single comment's thread. Return to all comments →
public static String getSmallestAndLargest(String s, int k) { java.util.SortedSet<String> set = new java.util.TreeSet<String>(); int len = s.length() - k; for(int i = 0; i<=len;i++){ set.add(s.substring(i, i+k)); } return set.first() + "\n" + set.last(); }
Java Substring Comparisons
You are viewing a single comment's thread. Return to all comments →