6 Line Python Soln


  • 1
    P

    Straight forward solution
    '''

    
    class Solution(object):
        def findLongestChain(self, pairs):
            pairs = sorted(pairs, key=lambda x: x[1])
            newli = [pairs[0]]
            for i in range(0, len(pairs)-1):
                if newli[len(newli)-1][1] < pairs[i + 1][0]:
                    newli.append(pairs[i + 1])
            return len(newli)
    

    '''


Log in to reply
 

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