Created
May 7, 2018 12:24
-
-
Save guysmoilov/9110db705164068b02eeda588974c375 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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