auto commit

This commit is contained in:
CyC2018 2020-11-01 15:58:29 +08:00
parent 3637b789d9
commit 7b755d9910
2 changed files with 12 additions and 8 deletions

View File

@ -108,11 +108,13 @@ public int eraseOverlapIntervals(int[][] intervals) {
Arrays.sort(intervals, new Comparator<int[]>() {
@Override
public int compare(int[] o1, int[] o2) {
return o1[1] - o2[1];
return (o1[1] < o2[1]) ? -1 : ((o1[1] == o2[1]) ? 0 : 1);
}
});
```
实现 compare() 函数时避免使用 `return o1[1] - o2[1];` 这种减法操作防止溢出
# 3. 投飞镖刺破气球
452\. Minimum Number of Arrows to Burst Balloons (Medium)

View File

@ -108,11 +108,13 @@ public int eraseOverlapIntervals(int[][] intervals) {
Arrays.sort(intervals, new Comparator<int[]>() {
@Override
public int compare(int[] o1, int[] o2) {
return o1[1] - o2[1];
return (o1[1] < o2[1]) ? -1 : ((o1[1] == o2[1]) ? 0 : 1);
}
});
```
实现 compare() 函数时避免使用 `return o1[1] - o2[1];` 这种减法操作防止溢出
# 3. 投飞镖刺破气球
452\. Minimum Number of Arrows to Burst Balloons (Medium)