Practice Maximum Score of Non-overlapping Intervals
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Maximum Score of Non-overlapping Intervals
Problem Statement
You are given a 2D integer array intervals, where intervals[i] = [li, ri, weighti]. Interval i starts at position li and ends at ri, and has a weight of weighti. You can choose up to 4 non-overlapping intervals. The score of the chosen intervals is defined as the total sum of their weights. Return the lexicographically smallest array of at most 4 indices from intervals with maximum score, representing your choice of non-overlapping intervals. Two intervals are said to be non-overlapping if they do not share any points. In particular, intervals sharing a left or right boundary are considered overlapping.
Source: Maximum Score of Non-overlapping Intervals on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
intervals = [[1,3,2],[4,5,2],[1,5,5],[6,9,3],[6,7,1],[8,9,1]]
[2,3]
# Example 2
intervals = [[5,8,1],[6,7,7],[4,7,3],[9,10,6],[7,8,2],[11,14,3],[3,5,5]]
[1,3,5,6]
Constraints
Related LeetCode Problems
Practice more problems similar to Maximum Score of Non-overlapping Intervals.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.