You are given an array of intervals
where each interval is represented by a pair [starti​,endi​]. The starti​ values are unique, meaning no two intervals begin at the same time.
The task is to find the right interval for each interval in the list. The right interval for an interval i is an interval j such that startj​>=endi​ and startj​ is minimized (i.e., it is the smallest start time among all valid intervals that is greater than or equal to endi​). Note that i may equal j.
Return an array of right interval indexes for each interval i. If no right interval exists for interval i, then put −1 at index i.
Constraints:
1≤ intervals.length
≤1000
intervals[i].length
==2
−106≤starti​≤endi​≤106
The start times are guaranteed to be unique.