Skip to content

Conversation

ngtduc693
Copy link
Contributor

Interval Scheduling (Greedy Algorithm)

Interval Scheduling solves the problem of selecting the maximum number of non-overlapping jobs (or intervals) from a given set. Each job has a start and end time. The greedy approach sorts jobs by their end time and iteratively selects jobs that do not overlap with previously chosen ones.

Use case

Work shift planning, meeting room booking, resource allocation.

Unit Test Evidence

image
  • I have performed a self-review of my code
  • My code follows the style guidelines of this project
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Comments in areas I changed are up to date
  • I have added comments to hard-to-understand areas of my code
  • I have made corresponding changes to the README.md

@ngtduc693 ngtduc693 marked this pull request as ready for review October 4, 2025 16:02
@ngtduc693 ngtduc693 requested a review from siriak as a code owner October 4, 2025 16:02
@ngtduc693 ngtduc693 force-pushed the feature/interval-scheduling-solver branch from 7e073f6 to d720622 Compare October 4, 2025 16:04
Copy link

codecov bot commented Oct 4, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.63%. Comparing base (e2c20ed) to head (b9ce9b5).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #537      +/-   ##
==========================================
- Coverage   96.64%   96.63%   -0.01%     
==========================================
  Files         275      277       +2     
  Lines       10865    10883      +18     
  Branches     1541     1544       +3     
==========================================
+ Hits        10500    10517      +17     
  Misses        232      232              
- Partials      133      134       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ngtduc693 ngtduc693 force-pushed the feature/interval-scheduling-solver branch from d720622 to 6017b94 Compare October 4, 2025 16:31
@siriak siriak requested a review from Copilot October 4, 2025 21:09
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request adds an Interval Scheduling implementation using a greedy algorithm to solve the problem of selecting the maximum number of non-overlapping jobs from a given set. The algorithm sorts jobs by their end time and iteratively selects jobs that don't overlap with previously chosen ones.

Key changes:

  • Implementation of greedy interval scheduling algorithm
  • Comprehensive test suite covering edge cases and various scenarios
  • Documentation updates to include the new algorithm in the project structure

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 4 comments.

File Description
README.md Added documentation entries for Job Scheduling algorithms including Interval Scheduling
Algorithms/Problems/JobScheduling/Job.cs Defines a Job record representing intervals with start and end times
Algorithms/Problems/JobScheduling/IntervalSchedulingSolver.cs Implements the greedy interval scheduling algorithm
Algorithms.Tests/Problems/JobScheduling/IntervalSchedulingSolverTests.cs Comprehensive test suite covering various scheduling scenarios

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@siriak
Copy link
Member

siriak commented Oct 4, 2025

Please check review comments

@ngtduc693 ngtduc693 force-pushed the feature/interval-scheduling-solver branch from c7a8407 to 07b91b4 Compare October 5, 2025 02:32
@ngtduc693
Copy link
Contributor Author

ngtduc693 commented Oct 5, 2025

Please check review comments

I'm done @siriak

@siriak siriak requested a review from Copilot October 5, 2025 20:46
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Member

@siriak siriak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good, thanks!

@siriak siriak merged commit a361c66 into TheAlgorithms:master Oct 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants