Python O(nlogn) complexity, easy to understand I think and Thx to Stefan!


  • 0

    '''
    class Solution(object):
    def lengthOfLIS(self, nums):

        if not nums:
            return 0
        
        inc = [float('inf')]*len(nums)
        for i in nums:
            inc[bisect.bisect_left(inc,i)]=i
        for i,v in enumerate(inc):
            if v > 2**31:
                return i
        return len(nums)
    

    '''


Log in to reply
 

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