Katkat

Find integer in most intervals

MetaSoftware Engineer · Onsite

Last updated

This question evaluates a candidate's ability to reason about interval overlap counting, manage range endpoints efficiently, and balance time-space trade-offs when identifying points that maximize coverage.

Question

Given N integer intervals [ai, bi] (positive integers), find an integer that belongs to the maximum number of intervals (return any such integer if several exist). Follow-up: When every endpoint is < M and M is small, how would you optimize?