简体   繁体   English

找到给定整数数组 A 的最长递增子序列

[英]Find the longest increasing subsequence of a given array of integers, A

Please dont post code请不要发布代码

find a subsequence of array in which the subsequence's elements are in strictly increasing order, and in which the subsequence is as long as possible.找到数组的子序列,其中子序列的元素严格按递增顺序排列,并且子序列尽可能长。 This subsequence is not necessarily contiguous, or unique.该子序列不一定是连续的或唯一的。 In this case, we only care about the length of the longest increasing subsequence.在这种情况下,我们只关心最长递增子序列的长度。

Input 1:
    A = [1, 2, 1, 5]

Output 1:
    3
    
Explanation 1:
    The sequence : [1, 2, 5]

Input 2:
    A = [0, 8, 4, 12, 2, 10, 6, 14, 1, 9, 5, 13, 3, 11, 7, 15]
    
Output 2:
    6

Explanation 2:
    The sequence : [0, 2, 6, 9, 13, 15] or [0, 4, 6, 9, 11, 15] or [0, 4, 6, 9, 13, 15]

My doubt how is this sequence formed [0, 2, 6, 9, 13, 15] what will be the next number.Is this sequence[0, 2, 6, 9, 13, 15] resembles anything common with this sequence [0, 4, 6, 9, 11, 15]我怀疑这个序列是如何形成的 [0, 2, 6, 9, 13, 15] 下一个数字是什么。这个序列 [0, 2, 6, 9, 13, 15] 是否类似于这个序列的任何常见内容 [ 0、4、6、9、11、15]

You can't select any correct sequence for further.你不能 select 任何正确的序列进一步。 But we have some comparison.但我们有一些比较。 Let's assume that there are 2 lists, A and B: if len(A) >= len(B) and A[-1] <= B[-1]: It's better to select A than B.假设有 2 个列表,A 和 B:如果 len(A) >= len(B) 和 A[-1] <= B[-1]:select A 比 B 好。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM