':type nums: List[int]
:rtype: int'

def lengthOfLIS(self, nums):

    LIS = []
    def insert(target):
        (left, right) = (0, (len(LIS) - 1))
        while (left <= right):
            mid = (left + ((right - left) / 2))
            if (LIS[mid] >= target):
                right = (mid - 1)
            else:
                left = (mid + 1)
        if (left == len(LIS)):
            LIS.append(target)
        else:
            LIS[left] = target
    for num in nums:
        insert(num)
    return len(LIS)
