Range intersection


  • 1
    A

    Given a series of ranges of integers, find if there exists an intersecting range common to all the ranges.
    Eg. [1, 5], [4, 10], [2, 11] --> intersecting range [4, 5]
    Eg. [4, 10], [1, 5], [2, 3] --> No intersecting range

    Solve in linear time.


  • 4

    two approaches I can provide:

    1. take two range and find their intersection. take the intersection and next range to get a new intersection, and so on.
    2. the ranges are [Ai, Bi]. The intersection is [max(Ai), min(Bi)].

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.