updated Trie problem

This commit is contained in:
rshaghoulian
2017-04-26 16:15:39 -07:00
parent 4bc5d0be0a
commit 9b6ef0f13b
9 changed files with 108 additions and 89 deletions
@@ -64,10 +64,9 @@ public class Solution {
}
class StudentComparator implements Comparator<Student> {
double epsilon = 0.001; // since we shouldn't use "==" with doubles
@Override
public int compare(Student s1, Student s2) {
if (Math.abs(s1.getCgpa() - s2.getCgpa()) > epsilon) {
if (Double.compare(s1.getCgpa(), s2.getCgpa()) != 0) {
return s1.getCgpa() < s2.getCgpa() ? 1 : -1; // descending order
} else if ( ! s1.getFname().equals(s2.getFname())) {
return s1.getFname().compareTo(s2.getFname());