Facebook | Phone Screen | Point in max overlapping intervals

Difficulty: MEDIUMCategory: InterviewExperienceFrequency: 1Asked On 2019-10-03Added By Anonymous
Source: Link

Company: Meta (Facebook)
Role: unknown
Interview Stage: Phone Screen
Location: unknown
Year: unknown

Original Post Content:

Given number M and N intervals in the form [a, b] (inclusive) where for every interval -M <= a <= b <= M, create a program that returns a point where the maximum number of intervals overlap.

Example:
M: 10
N: 4
Intervals:
• `[-3, 5]`
• `[0, 2]`
• `[8, 10]`
• `[6, 7]`

A correct answer would be either `0` ,`1` or `2` since those points are found where 2 intervals overlap and 2 is the maximum number of overlapping intervals.

Comments