Skip to content

Instantly share code, notes, and snippets.

@guysmoilov
Created May 7, 2018 12:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guysmoilov/9110db705164068b02eeda588974c375 to your computer and use it in GitHub Desktop.
Save guysmoilov/9110db705164068b02eeda588974c375 to your computer and use it in GitHub Desktop.
import java.util.Comparator;
import java.util.List;
/**
???
**/
public class Mystery<T extends Comparable<? super T>> implements Comparator<List<T>> {
@Override
public int compare(List<T> l1, List<T> l2) {
for (int i = 0; i < l1.size() && i < l2.size(); i++) {
T c1 = l1.get(i);
T c2 = l2.get(i);
int c = c1.compareTo(c2);
if (c != 0) {
return c;
}
}
return l2.size() - l1.size();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment