Find Right Interval

Medium · Intervals · about 20 minutes

Asked at Google, Amazon, Microsoft.

Each intervals[i] = [start, end] has a unique start. The right interval of i is the interval j with the smallest start_j such that start_j >= end_i (j may equal i). Return, for each interval, the index of its right interval, or -1.

Related guides