Skip to main content
hardNeetCode 150

Minimum Interval to Include Each Query

Time Range Finder You're building a calendar app that finds the shortest time slot that includes each meeting. Given intervals [start, end] and query times, find the smallest interval containing each query. Return -1 if no interval contains the query. Example: intervals = [[1,4],[2,4],[3,6],[4,4]], queries = [2,3,4,5] → [3,3,1,4]

Binary search is the tool here, but the real test is whether your invariant stays crisp. It's a hard one for a reason: it stresses boundary precision when the rules pile up. Interviewers care more about airtight boundaries than speed here.

Arrays & HashingHeap / Priority QueueBinary SearchIntervalsMath & Geometry

Meet Coco

Coco is an AI study partner, not a person. She listens while you explain your code, asks what a line does and never hands you the fix. Sign in free to type with Coco, up to a daily limit, and to talk with her for one hour. After that, talking comes with the $79 pack. Anyone can open the editor and run their code.

1Minimum Interval Sizehard
Based onLeetCode