You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/java/com/fishercoder/solutions/_435.java
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -11,6 +11,9 @@ public static class Solution1 {
11
11
* and https://discuss.leetcode.com/topic/65594/java-least-is-most
12
12
* Sort the intervals by their end time, if equal, then sort by their start time.
13
13
* 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.