How to determine the longest increasing subsequence using dynamic programming?

前端 未结 19 2584
醉梦人生
醉梦人生 2020-11-22 10:55

I have a set of integers. I want to find the longest increasing subsequence of that set using dynamic programming.

19条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-22 11:23

    Here is my Leetcode solution using Binary Search:->

    class Solution:
        def binary_search(self,s,x):
            low=0
            high=len(s)-1
            flag=1
            while low<=high:
                  mid=(high+low)//2
                  if s[mid]==x:
                     flag=0
                     break
                  elif s[mid] int:
             if not nums:
                return 0
             s=[]
             s.append(nums[0])
             for i in range(1,len(nums)):
                 if s[-1]

提交回复
热议问题