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 1–30 of 181 results

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

    Auto-gradedintervalssortingarraysgreedy
  • 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.

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

    Auto-gradedgreedyarraysmath
  • 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.

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

    Auto-gradedintervalssortinggreedysweep
  • 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.

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

    Auto-gradedstacksortingintervalsstrings
  • 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.

    Auto-gradedsweep-lineintervalsstep-functionbinary-search
  • Find the maximum integer less than or equal to n whose decimal digits do not decrease from left to right.

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

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

    Auto-gradedintervalsheapgreedysorting
  • Consolidate overlapping and adjacent closed intervals into a minimal list of disjoint intervals using sorting.

    Auto-gradedarraysgreedy-intervalssorting
  • 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.

    Auto-gradedsweep-lineintervalsdifference-arraysorting
  • Find the maximum average throughput over a continuous time window of a specified size, given rate logs over uniform time ticks.

    Auto-gradedsliding-windowtwo-pointersgreedyprefix-sum
  • 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.

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

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

    Model answersweep-lineintervalshash-mapsorting
  • Linearly interpolate a percentile value across histogram buckets assuming uniform distribution within each interval.

    Auto-gradedmathintervalshistogrampercentile
  • 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.

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

    Auto-gradedintervalsoverlapsimulationarrays
  • 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.

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

    Auto-gradeddesignsimulationintervalssorting
  • 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.

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

    Auto-gradedintervalssortinggreedyarrays
  • 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.

    Auto-gradedsweep-lineintervalssortinghalf-open-intervals
  • 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.

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

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

    Auto-gradedgreedyintervalssorting
  • 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.

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

    Auto-gradedsweep-lineintervalsevent-sortingsimulation

More topics