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.
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-conditionsFind the maximum aggregate load over a set of half-open intervals and identify the earliest contiguous time window sustaining it.
Auto-gradedsweep-lineintervalsarrayssortingParse 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-gradedgreedystringsparsingsortingTruncate overlapping integer intervals so no point is covered by more than k ranges while minimizing the total removed coverage.
Model answerintervalssweep-lineheapgreedyCompute 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-gradedgreedycountingschedulingmathImplement a decoder that converts token start and end logits into non-overlapping character spans using offset mappings and greedy selection.
Model answerstringsgreedy-intervalsmachine-learningsortingTurn 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-mapsortingMerge 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-lineFind 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-heapsortinggreedyCompute 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-updatesFind 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-thinkingFilter a chronological sequence of transaction records based on whether they fall within active premium membership intervals.
Auto-gradedintervalsdata-filteringhash-tableDetermine the minimum number of contiguous segments needed to split an array such that no segment's total sum exceeds a specified capacity limit.
Auto-gradedarraysgreedyFind 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-checkSimulate order executions under a time-windowed volume participation constraint using a sliding window.
Auto-gradedsliding-windowqueuegreedytime-seriesMerge 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-gradedintervalssortingsweepgreedyFind the largest set of intervals that all intersect one chosen anchor interval, using sorting and binary search to beat quadratic time.
Auto-gradedintervalsbinary-searchsortingcountingCount the fewest parenthesis insertions needed to make a string of brackets balanced, using a single left-to-right pass with a running counter.
Auto-gradedgreedystringsparenthesescounterDelete 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-gradedgreedystringstacksubsequenceFind 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-sumSplit 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-fillingarraysMerge overlapping or touching closed ranges, and count land regions in a binary grid that differ in shape when only shifting is allowed.
Auto-gradedintervalssortingdfsgridDetermine the minimum number of resources required to run a schedule of tasks given start and end times with boundary reuse allowed.
Auto-gradedgreedy-intervalsheaps-sortingarraysFind 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-linesortinggreedyCompute the maximum number of items processed by a sequential single-threaded worker within a total allowed time limit.
Auto-gradedgreedyarraysmathThree 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-sumsstackDecide 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-scanPerform greedy text wrapping to fixed line widths alongside dynamic interval point queries with insertion and removal.
Auto-gradedgreedyintervalsfenwick-treecoordinate-compressionProcess an unordered multi-asset market feed to find the maximum possible cumulative profit across all tickers.
Auto-gradedarraysgreedysortinghash-mapProcess chronological sensor sample logs to extract continuous active periods matching a minimum elapsed duration requirement.
Auto-gradedgreedy-intervalsarraystwo-pointers