You are given a list of integers. Your task is to find the longest increasing subsequence of the list. If there are multiple subsequences of equal length, you can choose any of them.
For example, in the list , the longest increasing subsequence contains numbers. The valid subsequences are , and .
In a file findlis.py
, implement the function find_sequence
that takes a list of integers as a parameter. The function should return a longest increasing subsequence of the list.
The function should be efficient when .
def find_sequence(numbers): # TODO if __name__ == "__main__": print(find_sequence([1, 2, 3])) # [1, 2, 3] print(find_sequence([3, 2, 1])) # [1] print(find_sequence([1, 1, 1, 1, 1])) # [1] print(find_sequence([1, 8, 2, 7, 3, 6])) # [1, 2, 3, 6] print(find_sequence([1, 1, 2, 2, 3, 3])) # [1, 2, 3] print(find_sequence([4, 1, 5, 6, 3, 4, 3, 8])) # [1, 3, 4, 8]