# Definition for an interval.
# class Interval(object):
# def __init__(self, s=0, e=0):
# self.start = s
# self.end = e
class Solution(object):
def findRightInterval(self, intervals):
"""
:type intervals: List[Interval]
:rtype: List[int]
"""
l=sorted((interval.start,pos) for pos,interval in enumerate(intervals))
res=[]
for i in intervals:
#locate the first interval.start that's bigger than i.end
r=bisect.bisect(l,(i.end,))
res.append(l[r][1] if r<len(intervals) else -1)
return res
网友评论