Skip to content

LeetCode 435: Non-overlapping Intervals #74

@github-actions

Description

@github-actions

LeetCode 435: Non-overlapping Intervals

Category: Interval
Difficulty: See LeetCode
Solution File: src/interval/non_overlapping_intervals.py
Test File: tests/test_non_overlapping_intervals.py

Problem Description

Given an array of intervals where intervals[i] = [starti, endi], return the minimum number of
intervals you need to remove to make the rest of the intervals non-overlapping.

Example 1:
Input: intervals = [[1,2],[2,3],[3,4],[1,3]]
Output: 1
Explanation: [1,3] can be removed and the rest are non-overlapping.

Example 2:
Input: intervals = [[1,2],[1,2],[1,2]]
Output: 2

Constraints:

  • 1 <= intervals.length <= 10^5
  • intervals[i].length == 2

Tasks

  • Implement the solution in src/interval/non_overlapping_intervals.py
  • Ensure all test cases pass
  • Analyze time complexity
  • Analyze space complexity

Metadata

Metadata

Assignees

No one assigned

    Labels

    blind-75Blind 75 - Blind-75 problemsintervalBlind 75 - Interval problems

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions