Python easy to understand using defaultdict


  • 0
    P
    from collections import defaultdict
    class Solution(object):
        def findRightInterval(self, intervals):
            """
            :type intervals: List[Interval]
            :rtype: List[int]
            """
            dic = defaultdict(lambda: -1)
            for ind, interval in enumerate(intervals):
            	dic[ interval.start ] = ind
            res = []
            for i in intervals:
            	res.append( dic[ i.end ] )
            return res
    

  • 0
    W

    @Phillf wrong answer


Log in to reply
 

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