FastPrepFind First Common Availability
Problems/Find First Common Availability

Find First Common Availability

Datadog logoDatadog● EasyINTERNFULLTIMEPHONE SCREEN
QuestionFunctionExamplesConstraints

Problem statement

Source note: A firsthand Datadog internship interview report supplied both availability lists, the meeting duration, the earliest-common-slot objective, and the empty-list result. The source omitted endpoint semantics, sorting guarantees, bounds, and exact output fields; these are stated here for a deterministic practice contract, matching the core task at about 95%.

Special thanks: Big big thanks to Rachel for carrying!! ☁️

Two people have availability intervals slotsA and slotsB. Each interval is a pair [start, end] and can host a meeting from any time at or after start through time end.

Given a positive meeting duration dur, return the earliest common interval [start, start + dur] that fits inside one interval from each person's schedule. If no common interval is long enough, return an empty array.

Each person's intervals are sorted by start time and do not overlap within that person's schedule.

Function

findFirstAvailability(slotsA: int[][], slotsB: int[][], dur: int) → int[]

Examples

Example 1

slotsA = [[10,50],[60,120],[140,210]]slotsB = [[0,15],[60,70]]dur = 8return = [60,68]

The overlap [10, 15] is too short. The next overlap begins at 60 and lasts ten units, so the earliest eight-unit meeting is [60, 68].

Example 2

slotsA = [[10,20]]slotsB = [[15,25]]dur = 5return = [15,20]

The common interval has exactly the required duration.

Example 3

slotsA = [[1,2],[5,7]]slotsB = [[2,4],[7,9]]dur = 1return = []

The schedules only touch at endpoints and have no positive-length overlap.

Constraints

  • 0 <= slotsA.length, slotsB.length <= 100000
  • Every interval has exactly two integers [start, end] with 0 <= start < end <= 10^9.
  • Intervals in each input are sorted by start time and are pairwise non-overlapping.
  • 1 <= dur <= 10^9

More Datadog problems

  • Query Log MatchPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
  • Delete a Filesystem TreePHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
  • Grouped-Query Attention Forward PassPHONE SCREEN · Seen Jun 2026
All Datadog interview questionsSee Datadog hiring insights
Saved
public int[] findFirstAvailability(int[][] slotsA, int[][] slotsB, int dur) {
  // Write your code here.
}
Checking account…