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 1–30 of 181 results
Evaluate ability to sort and combine overlapping or adjacent half-open numerical intervals in linear-arithmetic time.
Auto-gradedintervalssortingarraysgreedyValidate 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-searchsortingDetermine the task type index that maximizes total revenue within a given time budget using floor division and custom tie-breaking rules.
Auto-gradedgreedyarraysmathGroup 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-gradedintervalsgeometrygcdhashingCombine unsorted inclusive integer ranges that share at least one point into disjoint spans ordered by start, testing endpoint handling, chained merges, and nesting.
Auto-gradedintervalssortinggreedysweepExpand 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-gradedintervalsdatetimesimulationsortingCombine stack-based Unix path normalization with sort-and-sweep merging of overlapping or touching closed ranges, returning both results in one list.
Auto-gradedstacksortingintervalsstringsMerge 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-searchFind the maximum integer less than or equal to n whose decimal digits do not decrease from left to right.
Model answergreedymath-bitsstringsCombine closed integer ranges that overlap or share an endpoint into disjoint blocks, tests sorting plus a single sweep and careful boundary handling.
Auto-gradedintervalssortinggreedysweepPartition half-open time intervals across the fewest resources, deterministically giving each booking the lowest-numbered free resource, using sorting and two heaps.
Auto-gradedintervalsheapgreedysortingConsolidate overlapping and adjacent closed intervals into a minimal list of disjoint intervals using sorting.
Auto-gradedarraysgreedy-intervalssortingFind 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-arraysortingFind the maximum average throughput over a continuous time window of a specified size, given rate logs over uniform time ticks.
Auto-gradedsliding-windowtwo-pointersgreedyprefix-sumCompute 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-lineintervalsgreedysortingCalculate maximum achievable gain for an asset sequence under single-trade and unlimited-trade restrictions.
Auto-gradedarraysgreedydynamic-programmingTurn 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-mapsortingLinearly interpolate a percentile value across histogram buckets assuming uniform distribution within each interval.
Auto-gradedmathintervalshistogrampercentileMaximize 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-gradedgreedystringsarrayssegmentsSum payouts for work sessions by intersecting each session with non-overlapping hourly wage bands, using interval overlap arithmetic.
Auto-gradedintervalsoverlapsimulationarraysGroup 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-gradedgeometryintervalshashingsortingSimulate employee shifts, structural updates, bonus intervals, filtering, and time-bounded payroll computations.
Auto-gradeddesignsimulationintervalssortingRemove 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-argumentTests sorting intervals and scanning adjacent pairs to detect overlaps under half-open interval rules, where touching endpoints are allowed.
Auto-gradedintervalssortinggreedyarraysCompute 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-intervalsDelete 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-gradedgreedystringssubsequencelexicographicFind the maximum number of overlapping intervals at any instant using sweep line or heap techniques.
Auto-gradedintervalssweep-lineheapsortingFind the largest subset of half-open time intervals that can run on one worker without overlap, testing greedy interval selection by earliest finish.
Auto-gradedgreedyintervalssortingGreedy 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-passneighborsSweep-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