Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit490edbd

Browse files
refactor 56
1 parentf0489b1 commit490edbd

File tree

1 file changed

+1
-1
lines changed
  • src/main/java/com/fishercoder/solutions

1 file changed

+1
-1
lines changed

‎src/main/java/com/fishercoder/solutions/_56.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public static class Solution1 {
1212
*/
1313
publicint[][]merge(int[][]intervals) {
1414
List<int[]>list =newArrayList<>();
15-
Arrays.sort(intervals, (a,b) ->a[0] !=b[0] ?a[0] -b[0] :a[1] -b[1]);
15+
Arrays.sort(intervals, (a,b) ->Integer.compare(a[0],b[0]));//to avoid integer subtraction overflow
1616
for (inti =0;i <intervals.length;i++) {
1717
intstart =intervals[i][0];
1818
intend =intervals[i][1];

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp