Skip to content

feat(algorithms, intervals): remove covered intervals - #392

Merged
BrianLusina merged 1 commit into
mainfrom
feat/algorithms-intervals
Mar 7, 2026
Merged

feat(algorithms, intervals): remove covered intervals#392
BrianLusina merged 1 commit into
mainfrom
feat/algorithms-intervals

Conversation

@BrianLusina

@BrianLusina BrianLusina commented Mar 7, 2026

Copy link
Copy Markdown
Owner

Remove Covered Intervals

  • Add an algorithm?
  • Fix a bug or typo in an existing algorithm?
  • Documentation change?

Checklist:

  • This pull request is all my own work -- I have not plagiarized.
  • I know that pull requests will not be merged if they fail the automated tests.
  • This PR only changes one algorithm file. To ease review, please open separate PRs for separate algorithms.
  • All new TypeScript/JavaScript files are placed inside an existing directory.
  • All functions and variable names follow TypeScript/JavaScript naming conventions.
  • All new algorithms have a URL in its comments that points to Wikipedia or other similar explanation.
  • If this pull request resolves one or more open issues then the commit message contains Fixes: #{$ISSUE_NO}.

Summary by CodeRabbit

  • New Features

    • Added "Remove Covered Intervals" algorithm to identify and count non-covered intervals in a list.
  • Documentation

    • Added comprehensive documentation detailing the problem statement, coverage definition, solution approach, step-by-step algorithm, and time/space complexity analysis.
  • Tests

    • Added extensive test suite covering multiple scenarios including nested, disjoint, and mixed overlap cases.

@BrianLusina BrianLusina self-assigned this Mar 7, 2026
@BrianLusina BrianLusina added enhancement Algorithms Algorithm implementation Sorting Sorting algorithm or contains sorting Arrays Array Data structure Intervals labels Mar 7, 2026
@BrianLusina
BrianLusina merged commit f54a642 into main Mar 7, 2026
4 of 6 checks passed
@BrianLusina
BrianLusina deleted the feat/algorithms-intervals branch March 7, 2026 09:55
@coderabbitai

coderabbitai Bot commented Mar 7, 2026

Copy link
Copy Markdown

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 98220962-ceec-4c60-baaf-73944d4476ba

📥 Commits

Reviewing files that changed from the base of the PR and between 78e7732 and 3a612bc.

⛔ Files ignored due to path filters (12)
  • algorithms/intervals/removeIntervals/images/examples/remove_covered_intervals_example_1.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/examples/remove_covered_intervals_example_2.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/examples/remove_covered_intervals_example_3.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/examples/remove_covered_intervals_example_4.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/examples/remove_covered_intervals_example_5.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/solutions/remove_covered_intervals_solution_1.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/solutions/remove_covered_intervals_solution_2.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/solutions/remove_covered_intervals_solution_3.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/solutions/remove_covered_intervals_solution_4.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/solutions/remove_covered_intervals_solution_5.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/solutions/remove_covered_intervals_solution_6.png is excluded by !**/*.png
  • algorithms/intervals/removeIntervals/images/solutions/remove_covered_intervals_solution_7.png is excluded by !**/*.png
📒 Files selected for processing (3)
  • algorithms/intervals/removeIntervals/README.md
  • algorithms/intervals/removeIntervals/removeIntervals.test.ts
  • algorithms/intervals/removeIntervals/removeIntervals.ts

📝 Walkthrough

Walkthrough

A new algorithm solution for the "Remove Covered Intervals" problem has been added, consisting of a TypeScript implementation using a sorting and greedy iteration approach, comprehensive test coverage validating multiple scenarios, and detailed documentation explaining the problem definition, algorithm steps, and complexity analysis.

Changes

Cohort / File(s) Summary
Remove Covered Intervals Implementation
algorithms/intervals/removeIntervals/removeIntervals.ts, algorithms/intervals/removeIntervals/removeIntervals.test.ts, algorithms/intervals/removeIntervals/README.md
New algorithm implementation that counts non-covered intervals by sorting on start (ascending) and end (descending), then iterating with maxEndSeen tracking. Includes full test suite covering nested, disjoint, and mixed overlap scenarios, plus documentation detailing problem definition, solution approach, and O(n log n) time complexity.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Intervals sorted, overlaps shed,
A hop through coverage, logic spread,
Greedy iteration, clean and tidy,
No more shadows covering Friday! ✨

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/algorithms-intervals

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Algorithms Algorithm implementation Arrays Array Data structure enhancement Intervals Sorting Sorting algorithm or contains sorting

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant