Data Structures & AlgorithmsModerateProduct company OA · Amazon/Microsoft-style OA

Half-open intervals [1,5), [3,8), [10,12), [11,15). How many integer points lie in at least one of these intervals?

  1. A. 12
  2. B. 14
  3. C. 9
  4. D. 15

Correct answer: A. 12

Merge the overlapping intervals first: [1,8) covers seven points and [10,15) covers five, giving twelve. Adding the raw lengths double-counts the overlaps, which is the trap.

More Coding Interview Problems questions

Exams that ask this topic