How to determine the longest increasing subsequence using dynamic programming?

前端 未结 19 2364
醉梦人生
醉梦人生 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:25

    def longestincrsub(arr1):
        n=len(arr1)
        l=[1]*n
        for i in range(0,n):
            for j in range(0,i)  :
                if arr1[j]

    even though there is a way by which you can solve this in O(nlogn) time(this solves in O(n^2) time) but still this way gives the dynamic programming approach which is also good .

提交回复
热议问题