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

Commitf53161a

Browse files
refactor 435
1 parent45d9170 commitf53161a

File tree

1 file changed

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

1 file changed

+3
-0
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ public static class Solution1 {
1111
* and https://discuss.leetcode.com/topic/65594/java-least-is-most
1212
* Sort the intervals by their end time, if equal, then sort by their start time.
1313
* Then merge based on ending time.
14+
*
15+
* This comment is inspiring as of why sorting by end time could guarantee the correct answer: https://leetcode.com/problems/non-overlapping-intervals/discuss/91713/Java:-Least-is-Most/96271
16+
* In my words: if the earliest finished interval is not included, it's more likely that others (with later finish time) will overlap with others.
1417
*/
1518
publicinteraseOverlapIntervals(int[][]intervals) {
1619
Arrays.sort(intervals, (a,b) ->a[1] !=b[1] ?a[1] -b[1] :a[0] -b[0]);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp