KatInterview

practice a little every day — you've got this ♡

Greedy & Intervals Interview Problems

Practice 5971 original coding, SQL, system design, machine learning and behavioral problems across 15 topics. Coding and SQL problems run against hidden test cases right in your browser; every problem has hints and a worked solution, free.

5971
Problems
2211
Auto-graded
15
Topics
272
Added today

Showing 61–90 of 161 results

  • Greedy & IntervalsMediumAuto-graded
    Compute Free Windows from Schedule Constraints

    Compute unreserved time windows for specified daily schedules given opening hours and existing bookings.

    Greedy & Intervalsintervalssortingstringgreedy
  • Greedy & IntervalsMediumAuto-graded
    Resolve Overlapping Text Edit Spans by Priority

    Sweep over span boundaries with a heap to resolve overlapping inclusive edit spans using priority, original length, and input order, splitting losers into fragments.

    Greedy & Intervalsintervalssweep-lineheaptie-breaking
  • Greedy & IntervalsMediumAuto-graded
    Consolidate Overlapping Bookings in a Weekly Schedule

    Parse weekday and 24-hour time strings, then merge touching or overlapping same-day bookings and output them in a canonical, sorted string format.

    Greedy & Intervalsintervalssortingstring-parsingmerge-intervals
  • Greedy & IntervalsMediumAuto-graded
    Subscription Windows: Purchase Attribution and Anomaly Report

    Merge each user's subscription intervals, then attribute purchases to the merged windows, count September active days, and report out-of-window and overlap anomalies.

    Greedy & Intervalsintervalsmerge-intervalshash-mapdatetime
  • Greedy & IntervalsEasyAuto-graded
    Maximum Affordable Items Within Budget

    Determine the maximum collection of items that can be purchased given individual item costs and a total spending limit.

    Greedy & Intervalsgreedysortingarrays
  • Greedy & IntervalsEasyAuto-graded
    Find Peak Event Density in Fixed Duration Window

    Determine the maximum number of recorded logs occurring within a contiguous time interval using a sliding window approach.

    Greedy & Intervalssliding-windowtwo-pointersarraysintervals
  • Greedy & IntervalsMediumAuto-graded
    Weekly Deploy Windows with Time Zones and Blackouts

    Convert weekly recurring allow and freeze windows from local time zones to UTC, subtract the freezes, and list the first usable slots after a notice period.

    Greedy & Intervalsintervalssweep-linetime-zonesmodular-arithmetic
  • Greedy & IntervalsMediumAuto-graded
    Metered Usage Bill with Special Rate Windows

    Compute a total bill over a half-open time window where disjoint special-rate windows replace the default hourly rate, testing interval clipping and boundary handling.

    Greedy & Intervalsintervalssweepmatharrays
  • Greedy & IntervalsMediumAuto-graded
    Analyze Schedule Capacity and Overlaps

    Evaluate interval concurrency to determine if single-resource scheduling is possible and calculate peak concurrent demand.

    Greedy & Intervalsintervalssortingheapsweep-line
  • Greedy & IntervalsMediumAuto-graded
    Insert and Merge Interval into Sorted Collection

    Incorporate a target range into an already sorted list of disjoint closed intervals, merging any overlapping or adjacent spans in linear time.

    Greedy & Intervalsintervalsarraysgreedy
  • Greedy & IntervalsMediumAuto-graded
    Find the Maximum Size Connected Interval Component

    Find the maximum number of intervals that belong to a single connected component where edges represent inclusive interval overlaps.

    Greedy & Intervalsintervalssortinggreedygraphs
  • Greedy & IntervalsEasyAuto-graded
    Split Chores Between Two Workers With a Fixed Quota

    Choose exactly k items for the first worker to maximize total payoff, which tests reducing a problem to per-item differences and greedy top-k selection.

    Greedy & Intervalsgreedysortingarraysexchange-argument
  • Greedy & IntervalsMediumAuto-graded
    Earliest Shared Free Slot Across Several Schedules

    Find the earliest meeting slot of a given length that fits inside everyone's availability window and avoids every busy block, by intersecting windows and merging busy intervals.

    Greedy & Intervalsintervalssweep-linesortingscheduling
  • Greedy & IntervalsMediumAuto-graded
    Merge Event Windows Within Each Locality

    Join two record lists by id, group event time ranges by locality, merge overlapping or touching ranges, and return the merged windows in a specified sort order.

    Greedy & Intervalsintervalsmerge-intervalshash-mapsorting
  • Greedy & IntervalsMediumAuto-graded
    Minimum Removals for Conflict-Free Time Slots

    Tests the greedy earliest-finish strategy: find the fewest ranges to discard so the rest share no interior points, with touching endpoints allowed.

    Greedy & Intervalsgreedyintervalssortinginterval-scheduling
  • Greedy & IntervalsMediumAuto-graded
    Fewest Vehicles to Cover Back-to-Back Bookings

    Find the peak number of simultaneously active half-open intervals using a sweep line or heap, with correct handling of ties where one booking ends as another begins.

    Greedy & Intervalsintervalssweep-linesortingheap
  • Greedy & IntervalsMediumAuto-graded
    Sequential Allow/Deny Rules Over an IPv4 Block

    Track an IPv4 block as disjoint integer intervals while applying ordered allow and deny CIDR rules, deciding whether the block ends up fully covered with no deny hit.

    Greedy & Intervalsintervalsipv4cidrsimulation
  • Greedy & IntervalsMediumAuto-graded
    Courier Earnings from Overlapping Order Events

    Sweep over unsorted start/end events to total concurrency-weighted seconds, validate malformed input, and convert to a half-up rounded dollar string.

    Greedy & Intervalsinterval sweepevent sortingvalidationexact arithmetic
  • Greedy & IntervalsMediumAuto-graded
    Emptying Depots With a Limited Pool of Partner Skips

    Compute the minimum skips each depot needs using modular arithmetic, then greedily pick the cheapest depots under a shared skip budget to maximize emptied depots.

    Greedy & Intervalsgreedymathsortingmodular-arithmetic
  • Greedy & IntervalsEasyAuto-graded
    Best Single Buy-Sell Gain from Daily Quotes

    Find the largest gain from buying on one day and selling on a later day in a list of daily prices, returning 0 if no gain is possible.

    Greedy & Intervalsgreedyarraysrunning-minimumsingle-pass
  • Greedy & IntervalsMediumAuto-graded
    Fewest Conference Rooms for a Day of Bookings

    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.

    Greedy & Intervalsintervalsheapsweep-linesorting
  • Greedy & IntervalsMediumAuto-graded
    Fewest Drivers to Cover Every Trip Without Overlap

    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.

    Greedy & Intervalsintervalssweep-lineheapgreedy
  • Greedy & IntervalsMediumAuto-graded
    Find the First Free Slot After Busy Minutes in Text Schedules

    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.

    Greedy & Intervalsintervalsmerge-intervalsstring-parsingsorting
  • Greedy & IntervalsMediumAuto-graded
    Stock Piles Priced by Remaining Count: Maximum Earnings

    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.

    Greedy & Intervalsgreedysortingarithmetic-seriesmath
  • Greedy & IntervalsMediumAuto-graded
    Collapse Overlapping Time Ranges Into Disjoint Blocks

    Sort closed integer ranges and sweep once to combine any that overlap or touch, returning the minimal ordered list of disjoint ranges.

    Greedy & Intervalsintervalssortingsweepgreedy
  • Greedy & IntervalsMediumAuto-graded
    Peak Concurrent Shifts Across Half-Open Time Ranges

    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.

    Greedy & Intervalssweep-lineintervalssortinghash-map
  • Greedy & IntervalsMediumAuto-graded
    Courier Earnings from Overlapping Order Timelines

    Sweep over unsorted accept/fulfill events to total a courier's earnings, where pay per minute scales with the number of simultaneously open orders.

    Greedy & Intervalssweep-linesortingintervalssimulation
  • Greedy & IntervalsMediumAuto-graded
    Booked Time and Peak Room Demand for a Schedule

    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.

    Greedy & Intervalsintervalssweep-linesortingmerge-intervals
  • Greedy & IntervalsMediumAuto-graded
    Pick One Day Per Workshop Within Its Availability Window

    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.

    Greedy & Intervalsgreedyheapintervalssorting
  • Greedy & IntervalsMediumAuto-graded
    Daily Flat-Fee Cap on Overlapping Job Charges

    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.

    Greedy & Intervalsline-sweepintervalsdifference-arraymodular-arithmetic