KatInterview

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

Greedy & Intervals Interview Problems

Practice 5965 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.

5965
Problems
2208
Auto-graded
15
Topics
271
Added today

Showing 1–30 of 181 results

  • Greedy & IntervalsMediumAuto-graded
    Consolidate Overlapping Time Intervals

    Evaluate ability to sort and combine overlapping or adjacent half-open numerical intervals in linear-arithmetic time.

    Greedy & Intervalsintervalssortingarraysgreedy
  • Greedy & IntervalsMediumAuto-graded
    Pair Lab Visits with Follow-Up Consultations from 10-Minute Slots

    Validate and merge 10-minute availability slots, expand them into 30-minute visits, and list every lab-then-consultation pairing with a wait of 0 to 60 minutes.

    Greedy & Intervalsintervalsmergingbinary-searchsorting
  • Greedy & IntervalsEasyAuto-graded
    Select Best Single Task Type

    Determine the task type index that maximizes total revenue within a given time budget using floor division and custom tie-breaking rules.

    Greedy & Intervalsgreedyarraysmath
  • Greedy & IntervalsHardAuto-graded
    Union Overlapping Road Pieces That Share a Straight Line

    Group integer-point polylines by the exact line they lie on, then merge overlapping or touching extents on each line into one sorted point list.

    Greedy & Intervalsintervalsgeometrygcdhashing
  • Greedy & IntervalsMediumAuto-graded
    Coalesce Overlapping Ranges Into Disjoint Spans

    Combine unsorted inclusive integer ranges that share at least one point into disjoint spans ordered by start, testing endpoint handling, chained merges, and nesting.

    Greedy & Intervalsintervalssortinggreedysweep
  • Greedy & IntervalsMediumAuto-graded
    Open Half-Hour Slots from Weekly Hours and Bookings

    Expand a weekly schedule over a date range and subtract booked intervals to list every free, half-hour-aligned 30-minute slot in chronological order.

    Greedy & Intervalsintervalsdatetimesimulationsorting
  • Greedy & IntervalsMediumAuto-graded
    Canonical Path Cleanup Plus Overlapping Range Union

    Combine stack-based Unix path normalization with sort-and-sweep merging of overlapping or touching closed ranges, returning both results in one list.

    Greedy & Intervalsstacksortingintervalsstrings
  • Greedy & IntervalsHardAuto-graded
    Shared High-Activity Windows Across Sensor Feeds

    Merge step-function sensor feeds with a sweep over status-change events to find every maximal inclusive window in which all feeds are at or above a level.

    Greedy & Intervalssweep-lineintervalsstep-functionbinary-search
  • Greedy & IntervalsMediumModel answer
    Find the Largest Non-Decreasing Integer Below N

    Find the maximum integer less than or equal to n whose decimal digits do not decrease from left to right.

    Greedy & Intervalsgreedymath-bitsstrings
  • Greedy & IntervalsMediumAuto-graded
    Collapse Booked Time Ranges Into Disjoint Blocks

    Combine closed integer ranges that overlap or share an endpoint into disjoint blocks, tests sorting plus a single sweep and careful boundary handling.

    Greedy & Intervalsintervalssortinggreedysweep
  • Greedy & IntervalsMediumAuto-graded
    Smallest-ID Room Allocation for Booking Time Slots

    Partition half-open time intervals across the fewest resources, deterministically giving each booking the lowest-numbered free resource, using sorting and two heaps.

    Greedy & Intervalsintervalsheapgreedysorting
  • Greedy & IntervalsMediumAuto-graded
    Combine Overlapping Time Intervals

    Consolidate overlapping and adjacent closed intervals into a minimal list of disjoint intervals using sorting.

    Greedy & Intervalsarraysgreedy-intervalssorting
  • Greedy & IntervalsMediumAuto-graded
    Most Overlapped Aisle Along a Line of Lamps

    Find the integer position covered by the most symmetric intervals, returning the smallest on ties, using an event sweep over interval endpoints instead of visiting every position.

    Greedy & Intervalssweep-lineintervalsdifference-arraysorting
  • Greedy & IntervalsMediumAuto-graded
    Max Speed Continuous Window on Ticked Rate Stream

    Find the maximum average throughput over a continuous time window of a specified size, given rate logs over uniform time ticks.

    Greedy & Intervalssliding-windowtwo-pointersgreedyprefix-sum
  • Greedy & IntervalsMediumAuto-graded
    Peak Crew Size for Scheduled Shifts

    Compute the smallest crew that covers every scheduled task by finding the peak simultaneous demand, treating each task as half-open and parsing HH:MM times.

    Greedy & Intervalssweep-lineintervalsgreedysorting
  • Greedy & IntervalsMediumAuto-graded
    Max Gains from Single and Multi-Trade Asset Strategies

    Calculate maximum achievable gain for an asset sequence under single-trade and unlimited-trade restrictions.

    Greedy & Intervalsarraysgreedydynamic-programming
  • Greedy & IntervalsMediumModel answer
    Staffing Timeline from Overlapping Work Shifts

    Turn a list of overlapping employee shifts into contiguous time segments, each listing who is on duty, with empty segments marking gaps in coverage.

    Greedy & Intervalssweep-lineintervalshash-mapsorting
  • Greedy & IntervalsMediumAuto-graded
    Estimate Percentile from Histogram Buckets

    Linearly interpolate a percentile value across histogram buckets assuming uniform distribution within each interval.

    Greedy & Intervalsmathintervalshistogrampercentile
  • Greedy & IntervalsMediumAuto-graded
    Sentinels on a Road: Best Covered Value With Single Left Steps

    Maximize the total value of covered towns on a line when each sentinel may step one town left at most once into an empty town, by finding which town each run of sentinels leaves uncovered.

    Greedy & Intervalsgreedystringsarrayssegments
  • Greedy & IntervalsEasyAuto-graded
    Shift Pay Totals Across Time-of-Day Wage Bands

    Sum payouts for work sessions by intersecting each session with non-overlapping hourly wage bands, using interval overlap arithmetic.

    Greedy & Intervalsintervalsoverlapsimulationarrays
  • Greedy & IntervalsHardAuto-graded
    Fuse Collinear Point Chains Along Shared Lines

    Group point lists by the infinite line they lie on, then fuse those that overlap or touch along that line, and return each fused group's unique points ordered along the line.

    Greedy & Intervalsgeometryintervalshashingsorting
  • Greedy & IntervalsMediumAuto-graded
    Shift Tracker and Earnings Simulator

    Simulate employee shifts, structural updates, bonus intervals, filtering, and time-bounded payroll computations.

    Greedy & Intervalsdesignsimulationintervalssorting
  • Greedy & IntervalsMediumAuto-graded
    Best Result After Removing a Single Five from a Number String

    Remove exactly one '5' from a digit string to get the lexicographically largest result of equal length, using a greedy scan and preserving leading zeros.

    Greedy & Intervalsgreedystringsdigitsexchange-argument
  • Greedy & IntervalsEasyAuto-graded
    Conflict-Free Schedule Check for a Single Attendee

    Tests sorting intervals and scanning adjacent pairs to detect overlaps under half-open interval rules, where touching endpoints are allowed.

    Greedy & Intervalsintervalssortinggreedyarrays
  • Greedy & IntervalsMediumAuto-graded
    Peak Overlap of Half-Open Time Ranges

    Compute the largest number of simultaneously running half-open time ranges using a sweep over sorted start and end events, with correct handling of ties at boundaries.

    Greedy & Intervalssweep-lineintervalssortinghalf-open-intervals
  • Greedy & IntervalsMediumAuto-graded
    Maximum Number With Even Counts of Ones and Twos

    Delete characters from a string of 1s and 2s so both digit counts are even, and return the largest possible number. Tests greedy subsequence construction with count constraints.

    Greedy & Intervalsgreedystringssubsequencelexicographic
  • Greedy & IntervalsMediumAuto-graded
    Minimum Concurrent Resources for Overlapping Intervals

    Find the maximum number of overlapping intervals at any instant using sweep line or heap techniques.

    Greedy & Intervalsintervalssweep-lineheapsorting
  • Greedy & IntervalsMediumAuto-graded
    Largest Set of Compatible Time Slots on One Worker

    Find the largest subset of half-open time intervals that can run on one worker without overlap, testing greedy interval selection by earliest finish.

    Greedy & Intervalsgreedyintervalssorting
  • Greedy & IntervalsMediumAuto-graded
    Fewest Badges for a Row of Scored Players

    Greedy two-pass array problem: assign the minimum total badges so each player gets at least one and any player scoring higher than an adjacent player gets strictly more badges.

    Greedy & Intervalsgreedyarraytwo-passneighbors
  • Greedy & IntervalsMediumAuto-graded
    Courier Pay with Overlap Multipliers, Waits and Peak Windows

    Sweep-line over time intervals: pay grows with the square of concurrent deliveries, store-wait minutes are isolated, and peak windows double the rate.

    Greedy & Intervalssweep-lineintervalsevent-sortingsimulation