<jupyter_start><jupyter_text>Good Question!!  Classic ![image.png](attachment:image.png) https://www.youtube.com/watch?v=7DKFpWnaxLI<jupyter_code>nums=[10,9,2,5,3,7,101,18]

dp=[1]*(len(nums))
for i in range(1,len(nums)):
    for j in range(i):
        if nums[i] > nums[j]:
            dp[i]=max(dp[i],dp[j]+1)
    
res=max(dp)
print(res)<jupyter_output>4
2<jupyter_text>https://leetcode.com/problems/longest-increasing-subsequence/discuss/74824/JavaPython-Binary-search-O(nlogn)-time-with-explanation![image.png](attachment:image.png)<jupyter_code>def lengthOfLIS(self, nums):
    tails = [min(nums)-1] * len(nums)
    size = 0
    for x in nums:
        i, j = 0, size
        while i != j:
            m = (i + j) // 2
            if tails[m] < x:
                i = m + 1
            else:
                j = m
        tails[i] = x
        print(tails)
        size = max(i + 1, size)
    return size

nums=[10,1,2,5,3,7,101,18]
lengthOfLIS(0,nums)

def num_ways_X(n,X):
    if n==0: return 1
    total=0
    for i in X:
        if n-i >=0: total += num_ways_X(n-i,X)
    return total

def numways_X_bootomup(n,X):
    if n == 0: return 1
    nums = [0 for i in range(n+1)]
    
    nums[0]=1
    for i in range(1,n+1):
        total = 0
        for j in X:
            if i-j >=0 :
                total += nums[i-j]
        nums[i]=total
    return nums[n]
    
print(num_ways_X(6,[1,2]))
print(numways_X_bootomup(6,[1,2]))
4|1<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.16439290586630287, 'fraction_numerical': 0.04365620736698499, 'mean_word_length': 2.380184331797235, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, 'https://': 2, 'lorem ipsum': 0, 'www.': 1, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '71541', 'license': 'BSD-2-Clause', 'n_tokens_mistral': 658, 'n_tokens_neox': 619, 'n_words': 116, 'path': '300. Longest Increasing Subsequence.ipynb', 'repo_name': 'kkoo1122/Leetcode_Practice', 'size': '1466'}