Topic
Greedy & Intervals interview problems
Scheduling, interval merging and exchange arguments. 181 original problems, each with hidden test cases you can run in the browser.
24 easy144 medium13 hard
Showing 91–120 of 181 results
Compute the minimum number of rooms needed to host all time-range bookings when back-to-back bookings may reuse a room, testing sweep-line or heap-based interval reasoning.
Auto-gradedintervalsheapsweep-linesortingFind the fewest drivers needed to serve all trips given [start, end) times, which reduces to the peak number of simultaneous trips and tests sweep-line or heap handling of boundaries.
Auto-gradedintervalssweep-lineheapgreedyParse text schedule entries into inclusive minute intervals, merge them, and find the earliest k-minute free slot that follows the first busy minute of the day.
Auto-gradedintervalsmerge-intervalsstring-parsingsortingGreedy selling from the largest pile, solved in bulk with sorting and arithmetic-series sums because the number of sales is too large to simulate one by one.
Auto-gradedgreedysortingarithmetic-seriesmathSort closed integer ranges and sweep once to combine any that overlap or touch, returning the minimal ordered list of disjoint ranges.
Auto-gradedintervalssortingsweepgreedyBreak a set of possibly overlapping staffed time windows into disjoint half-open segments, each labeled with the sorted set of people covering it, dropping gaps and merging equal neighbors.
Model answersweep-lineintervalshash-mapsortingFind the largest number of half-open time ranges that overlap at one instant, handling shared endpoints, empty ranges and large inputs with a sweep over sorted boundaries.
Auto-gradedsweep-lineintervalssortinghash-mapSweep over unsorted accept/fulfill events to total a courier's earnings, where pay per minute scales with the number of simultaneously open orders.
Auto-gradedsweep-linesortingintervalssimulationCompute the total time covered by a set of half-open intervals and the maximum number of simultaneously active intervals, ignoring empty or reversed ones.
Auto-gradedintervalssweep-linesortingmerge-intervalsChoose a distinct day for as many workshops as possible, each within its own window, using an earliest-deadline-first greedy with a min-heap.
Auto-gradedgreedyheapintervalssortingTurn a day's delivery events into total driver pay, then add doubled-rate surge windows by splitting intervals at boundaries, and decide how to handle messy or inconsistent logs.
Model answerintervalsevent-processinghashingsortingSum per-day min(active cost, flat fee) over huge day ranges using an event sweep, with the result taken modulo 1,000,000,007.
Auto-gradedline-sweepintervalsdifference-arraymodular-arithmeticMerge half-open integer segments that overlap or touch end-to-start, then report the merged segments in order along with their combined covered length.
Auto-gradedintervalssortingsweepmergeUse unsorted gate scan records to find peak car occupancy and the maximal time windows at that peak, including when some exit scans are missing and stays are capped.
Model answersweep-lineintervalsevent-processingsortingTests interval overlap checks under half-open semantics and using binary search on sorted, disjoint bookings to find a free room quickly.
Auto-gradedintervalsbinary-searchsortinghalf-open-rangesTests whether a candidate can efficiently count how many inclusive ranges cover each of a set of query values using binary search decomposition.
Auto-gradedbinary-searchintervalssortingTests sweep-line techniques for interval overlap detection, event aggregation at boundaries, and proper handling of half-open interval semantics.
Auto-gradedintervalssweep-linesortingevent-processingTests greedy reasoning and sorting to maximize the sum of "lesser" elements across a constrained pairing of an even-length array.
Auto-gradedgreedysortingarraysMerge overlapping half-open intervals to return the total length covered by at least one interval.
Auto-gradedintervalssortingsweep-linemergeTests interval merging, overlap calculation, and time-based pay aggregation with capped rate multipliers.
Auto-gradedintervalsarraysmathTests greedy selection when items have uniform cost but different values under capacity constraints.
Auto-gradedgreedysortingmathGiven a list of fixed-time support tickets, assign each to an agent while respecting per-client concurrency caps and an optional agent pool size.
Model answergreedyinterval-schedulingheapsweep-lineGiven tasks with time windows and resource demands, find the fewest parallel workers needed so no worker exceeds capacity K at any moment.
Model answergreedyintervalsheapbin-packingParse sensor streams into continuous activity windows and find time ranges where all sensors are simultaneously active.
Model answerintervalstime-seriesintersectiontwo-pointersTests the sweep-line technique by computing, for each minute in a query list, how many camera recording intervals are active at that exact moment.
Auto-gradedsweep lineintervalsgreedysortingTests greedy selection with precomputation, prefix sums, and binary search to maximize item counts under budget constraints.
Auto-gradedgreedybinary-searchprefix-sumsortingDesign a fee-maximizing transaction selector for a size-capped block, extend it to parent/child dependencies with CPFP scoring, and derive a minimum child fee.
Model answergreedyknapsackdependency-trackingcryptocurrencyTests whether a candidate can apply a greedy sort-and-pair strategy to maximize the sum of pair minimums across a list of player ratings.
Auto-gradedgreedysortingarraysSweep merged busy intervals to find the earliest gap of a required duration that fits within every employee's working hours.
Model answerintervalsheapmergeschedulingTests the classic weighted job scheduling with deadlines: greedily select a maximum-profit feasible subset of unit-length tasks, each with a deadline and profit, using a disjoint-set (union-find) structure for efficiency.
Auto-gradedgreedyschedulingunion-findintervals