Find Bookable Interview Blocks Where Enough Interviewers Are Free

Last updated: November 29, 2026

Quick Overview

Given each interviewer's free intervals for a day, return every back-to-back block of a fixed length during which at least `need` interviewers are simultaneously free, so a panel or a pool of backups can be guaranteed.

Karat
Coding & Algorithms
Software Engineer
Karat
November 29, 2026
Software Engineer
Technical Screen
Coding & Algorithms
Medium

0

0

0 solved


Given each interviewer's free intervals for a day, return every back-to-back block of a fixed length during which at least `need` interviewers are simultaneously free, so a panel or a pool of backups can be guaranteed.

A natural second or third part after a basic overlap question: the problem moves from one person to a pool, which mirrors how an interviewing service guarantees capacity for a time slot. The interviewer is checking whether you reach for a sweep line, order tie events correctly, and slice windows cleanly.

What the Interviewer Expects
  • Model the problem as a sweep over +1 and -1 events
  • Order ends before starts at the same timestamp because ends are exclusive
  • Track when the free count crosses the `need` threshold in each direction
  • Merge windows that touch at a shared instant
  • Slice merged windows into fixed length blocks
Key Topics to Cover
sweep line
intervals
event ordering
threshold crossing
scheduling
How to Approach This
  1. Clarify input constraints and edge cases before writing code.
  2. Walk through your approach verbally and confirm with the interviewer before coding.
  3. Start with a brute force solution, then optimize. Mention time and space complexity.
  4. Test your solution with examples, including edge cases like empty input or duplicates.
  5. Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
  • How would you return which interviewers are free in each block?
  • Blocks must start on 15 minute boundaries. Adjust the slicing.
  • Availability is updated live as interviewers book. What data structure keeps queries fast?
  • How would you pick blocks to maximize total coverage across a week?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice DSA Problems
Sample Answer
Requirements

Input: {interviewer: [(start, end), ...]} in hours or minutes, end exclusive; length of a block; need minimum free count. Output: sorted list of non-overlapping (start, start + length) blocks ...

High-Level Design

Turn every interval into (start, +1) and (end, -1). Sorting tuples puts -1 before +1 at equal times, which is exactly right for exclusive ends. Sweep the count; when it rises from below need...


Submit Your Answer
Markdown supported

Related Questions