KatInterview

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.

Problems181

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-linesorting
  • Find 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-lineheapgreedy
  • Parse 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-parsingsorting
  • Greedy 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-seriesmath
  • Sort closed integer ranges and sweep once to combine any that overlap or touch, returning the minimal ordered list of disjoint ranges.

    Auto-gradedintervalssortingsweepgreedy
  • Break 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-mapsorting
  • Find 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-map
  • Sweep 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-linesortingintervalssimulation
  • Compute 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-intervals
  • Choose 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-gradedgreedyheapintervalssorting
  • Turn 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-processinghashingsorting
  • Sum 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-arithmetic
  • Merge 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-gradedintervalssortingsweepmerge
  • Use 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-processingsorting
  • Tests 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-ranges
  • Tests whether a candidate can efficiently count how many inclusive ranges cover each of a set of query values using binary search decomposition.

    Auto-gradedbinary-searchintervalssorting
  • Tests sweep-line techniques for interval overlap detection, event aggregation at boundaries, and proper handling of half-open interval semantics.

    Auto-gradedintervalssweep-linesortingevent-processing
  • Tests greedy reasoning and sorting to maximize the sum of "lesser" elements across a constrained pairing of an even-length array.

    Auto-gradedgreedysortingarrays
  • Merge overlapping half-open intervals to return the total length covered by at least one interval.

    Auto-gradedintervalssortingsweep-linemerge
  • Tests interval merging, overlap calculation, and time-based pay aggregation with capped rate multipliers.

    Auto-gradedintervalsarraysmath
  • Tests greedy selection when items have uniform cost but different values under capacity constraints.

    Auto-gradedgreedysortingmath
  • Given 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-line
  • Given tasks with time windows and resource demands, find the fewest parallel workers needed so no worker exceeds capacity K at any moment.

    Model answergreedyintervalsheapbin-packing
  • Parse sensor streams into continuous activity windows and find time ranges where all sensors are simultaneously active.

    Model answerintervalstime-seriesintersectiontwo-pointers
  • Tests 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 lineintervalsgreedysorting
  • Tests greedy selection with precomputation, prefix sums, and binary search to maximize item counts under budget constraints.

    Auto-gradedgreedybinary-searchprefix-sumsorting
  • Design 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-trackingcryptocurrency
  • Tests 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-gradedgreedysortingarrays
  • Sweep merged busy intervals to find the earliest gap of a required duration that fits within every employee's working hours.

    Model answerintervalsheapmergescheduling
  • Tests 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

More topics