Skip to content
Skills Library
Programming · Learning & explanation

dsa-greedy-algorithms-interval-scheduling

/dsa-greedy-algorithms-interval-scheduling

Use this skill when making locally optimal choices to solve interval scheduling, non-overlapping intervals, and meeting room problems.

Licence
MIT
Last repository change
28.10.2026

Assessment and security

100/ 100Class: good
Format25 / 25
Frontmatter with name and description, valid name, description up to 1,024 characters, name matching the folder.
Discoverability25 / 25
Description explains when to use the skill, has a reasonable length and uses third person.
Content35 / 35
At least 150 words and at most 500 lines, headings, step lists, examples or code.
Hygiene15 / 15
No placeholders such as TODO, no Windows paths, with a licence.
Riskno signals detected in the scan
Files in this package
1
Scripts
0
HTML comments
0
URLs in SKILL.md
0
Deprecation

No signals detected. Repository changed on 28.10.2026, without references to retired models or APIs.

Licence

MIT, open: use and modify while retaining author attribution.

What it does and when to use it

Use this skill when making locally optimal choices to solve interval scheduling, non-overlapping intervals, and meeting room problems.

Original author description

Use this skill when making locally optimal choices to solve interval scheduling, non-overlapping intervals, and meeting room problems.

How it works

  1. When to use
  2. Core principles
  3. Step-by-step workflow
  4. Specifics & examples
  5. Common mistakes & pitfalls
  6. Verification checklist
  7. Related skills
Original SKILL.md headings · 52 lines, 342 words
SKILL.md preview
---
name: dsa-greedy-algorithms-interval-scheduling
description: Use this skill when making locally optimal choices to solve interval scheduling, non-overlapping intervals, and meeting room problems.
---
# DSA: Greedy Algorithms & Interval Scheduling

## When to use
Use this skill when tasked with scheduling meetings, merging overlapping time blocks, finding minimum arrows to burst balloons, or gas station tour puzzles.

## Core principles
- **The Greedy Choice Property**: A globally optimal solution can be achieved by selecting locally optimal choices without re-evaluating past decisions.
- **Interval Sorting Heuristics**: Meeting room overlap problems sort by *start time*; maximum non-overlapping scheduling problems sort by *end time*.
- **Continuous Invariant Tracking**: Maintain a running boundary (e.g., `last_end_time`) to determine whether the next interval overlaps or can be cleanly accommodated.
- **When Greedy Fails**: Verify with the interviewer that the problem exhibits greedy choice property rather than requiring global DP optimization (like 0/1 knapsack).

## Step-by-step workflow
1. Sort intervals based on required criteria (`x[0]` for merge/start; `x[1]` for earliest deadline/end).
2. Initialize tracking variables (`merged_intervals = [intervals[0]]` or `last_end = intervals[0][1]`).
3. Iterate through sorted intervals from index 1.
4. Compare `current.start` with `last.end`: if overlapping, merge `last.end = max(last.end, current.end)` or count collision.
5. If non-overlapping, append interval or update `last_end`.
6. Return merged collection or count.

## Specifics & examples
```python
# Merge Overlapping Intervals: O(N log N) Time, O(N) Space
def merge_intervals(intervals: list[list[int]]) -> list[list[int]]:
    if not intervals:
        return []
    intervals.sort(key=lambda x: x[0])
    merged = [intervals[0]]
    for start, end in intervals[1:]:
        last_end = merged[-1][1]
        if start <= last_end:
            merged[-1][1] = max(last_end, end)
        else:
            merged.append([start, end])
    return merged
```

## Common mistakes & pitfalls
- Assuming intervals are pre-sorted without verifying with the interviewer.
- Using `start < last_end` instead of `start <= last_end` when touching intervals must be merged.
- Sorting by start time when the problem requires scheduling maximum independent events (requires sorting by end time).

## Verification checklist
- [ ] Explicitly sorted input intervals prior to greedy iteration.
- [ ] Correctly identified whether sorting by start time or end time is required.
- [ ] Handled edge case where intervals touch at boundaries.

## Related skills
- dsa-arrays-hashing-two-pointers-sliding-window
- dsa-heaps-priority-queues-top-k-elements
- dsa-time-space-complexity-big-o-analysis
- coding-interview-communication-thinking-out-loud

Versions

The database has no other skills named dsa-greedy-algorithms-interval-scheduling.

Database snapshot: 13.11.2026 · package version 42c4497b0f2a (SHA-256 digest of the entire package)

Downloads in the last 30 days: 3 · ranking

Report a problem with this skill: harmful content, incorrect descriptions or an author’s removal request.

Similar skills

  • 100search-and-optimization
    Reference patterns for search, optimization, and greedy algorithms. Covers binary search (classic and on-answer), two pointers, sliding window, greedy strategies, prefix sums, merge intervals, and monotonic stack. Use when solving problems that involve searching sorted data,…
  • 100dsa-next
    Find what to solve next based on target role and current progress. Use when a student asks "what should I solve next", "what problem should I do next", "next problem for my role", "recommend DSA problems", or asks for role-specific interview preparation.
  • 100interval-guided-regression-test-update
    Automatically updates regression tests based on interval analysis to maintain coverage of key program intervals. Use when code changes affect value ranges, conditionals, or control flow, and existing tests need updating to maintain interval coverage. Analyzes interval…
  • 100dsa-revise
    Track spaced repetition revision for DSA problems on your machine. Use when a student asks "revision due", "what should I revise", "spaced repetition", "check due problems", "log revision", or wants to check which problems are due for review.
  • 90role-algorithms:algorithm-design
    Designs algorithms with formal analysis — Big-O/Theta/Omega, amortized analysis, recurrence relations (Master theorem), correctness proofs (loop invariants, induction, reduction), and paradigm selection (greedy, divide-and-conquer, dynamic programming, backtracking). Use when…
  • 100dsa-dynamic-programming-1d-memoization-tabulation
    Use this skill when solving optimization, counting, and decision problems by breaking them into overlapping 1D sub-problems.

Feedback and reports

Your message goes to Bartosz Sokoliński. An email address is needed only for a reply. See the privacy policy.