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 31–60 of 181 results

  • Scan a list of closed integer ranges and return the indices of those lying entirely within a given query range, testing inclusive boundary handling.

    Auto-gradedintervalsarrayscanboundary-conditions
  • Find the maximum aggregate load over a set of half-open intervals and identify the earliest contiguous time window sustaining it.

    Auto-gradedsweep-lineintervalsarrayssorting
  • Parse decimal money strings exactly into cents, detect underpayment or exact payment, then greedily break the change into named bills and coins and output them sorted alphabetically.

    Auto-gradedgreedystringsparsingsorting
  • Truncate overlapping integer intervals so no point is covered by more than k ranges while minimizing the total removed coverage.

    Model answerintervalssweep-lineheapgreedy
  • Compute the shortest timeline needed to run labeled jobs when equal labels must be separated by a cooldown, using frequency counting and a greedy frame argument.

    Auto-gradedgreedycountingschedulingmath
  • Implement a decoder that converts token start and end logits into non-overlapping character spans using offset mappings and greedy selection.

    Model answerstringsgreedy-intervalsmachine-learningsorting
  • Turn a map of net balances into a deterministic list of payments that zeroes every account, using a sorted two-pointer greedy match between debtors and creditors.

    Auto-gradedgreedytwo-pointershash-mapsorting
  • Merge two sorted lists of internally disjoint closed intervals into one sorted, disjoint list, joining overlapping or endpoint-touching intervals, in linear time.

    Auto-gradedintervalstwo-pointersmergesweep-line
  • Find the smallest number of rooms that can host every booking at once, where a booking may begin the moment another one ends, using sorting and a min-heap.

    Auto-gradedintervalsmin-heapsortinggreedy
  • Compute the minimum number of +1 contiguous-segment updates needed to make an array non-decreasing, using adjacent differences and a lower-bound argument.

    Auto-gradeddifference-arraygreedyarraysrange-updates
  • Find the minimum number of decrement-by-one and double operations needed to turn one positive integer into another, which rewards working backward from the target with a greedy rule.

    Auto-gradedgreedymathreverse-thinking
  • Filter a chronological sequence of transaction records based on whether they fall within active premium membership intervals.

    Auto-gradedintervalsdata-filteringhash-table
  • Determine the minimum number of contiguous segments needed to split an array such that no segment's total sum exceeds a specified capacity limit.

    Auto-gradedarraysgreedy
  • Find how many days a growing-size distinct-item picking schedule can run, using binary search on the answer plus a capacity feasibility check.

    Auto-gradedgreedybinary-searchprefix-sumsfeasibility-check
  • Simulate order executions under a time-windowed volume participation constraint using a sliding window.

    Auto-gradedsliding-windowqueuegreedytime-series
  • Merge inclusive ranges that share at least one point into a sorted list of disjoint ranges, testing sorting, a linear sweep, and correct handling of touching endpoints and nesting.

    Auto-gradedintervalssortingsweepgreedy
  • Find the largest set of intervals that all intersect one chosen anchor interval, using sorting and binary search to beat quadratic time.

    Auto-gradedintervalsbinary-searchsortingcounting
  • Count the fewest parenthesis insertions needed to make a string of brackets balanced, using a single left-to-right pass with a running counter.

    Auto-gradedgreedystringsparenthesescounter
  • Delete characters from a string of 1s and 2s so both digit counts are even and the number is largest, testing greedy deletion with parity reasoning.

    Auto-gradedgreedystringstacksubsequence
  • Find the largest group size k where at least k people accept exactly k-1 companions, using interval counting with a difference array in linear time.

    Auto-gradeddifference-arrayintervalscountingprefix-sum
  • Split a budget as evenly as possible among people with individual caps, using a binary-searched fill level plus a lowest-index-first remainder rule.

    Auto-gradedgreedybinary-searchwater-fillingarrays
  • Merge overlapping or touching closed ranges, and count land regions in a binary grid that differ in shape when only shifting is allowed.

    Auto-gradedintervalssortingdfsgrid
  • Determine the minimum number of resources required to run a schedule of tasks given start and end times with boundary reuse allowed.

    Auto-gradedgreedy-intervalsheaps-sortingarrays
  • Find the fewest rooms that can host every booking in an unordered list of half-open time ranges, where back-to-back bookings may share a room.

    Auto-gradedintervalssweep-linesortinggreedy
  • Compute the maximum number of items processed by a sequential single-threaded worker within a total allowed time limit.

    Auto-gradedgreedyarraysmath
  • Three separate tasks: find an integer with the highest interval overlap, sum BST values within a range (plus many-query speedups), and compute per-function self time from nested start/end logs.

    Model answersweep-linebstprefix-sumsstack
  • Decide whether a proposed half-open time slot shares any time with a list of unsorted booked slots, testing overlap logic and correct handling of touching endpoints.

    Auto-gradedintervalsoverlaphalf-openlinear-scan
  • Perform greedy text wrapping to fixed line widths alongside dynamic interval point queries with insertion and removal.

    Auto-gradedgreedyintervalsfenwick-treecoordinate-compression
  • Process an unordered multi-asset market feed to find the maximum possible cumulative profit across all tickers.

    Auto-gradedarraysgreedysortinghash-map
  • Process chronological sensor sample logs to extract continuous active periods matching a minimum elapsed duration requirement.

    Auto-gradedgreedy-intervalsarraystwo-pointers

More topics