I have a this funtion
n=5
nums=5 1 4 2 3
def LIS(nums, n):
dp = []
dp_list = []
for i in range(n):
dp.append(1)
dp_list.append([nums[i]])
for j in range(i):
if nums[j] < nums[i]:
dp[i] = max(dp[i], dp[j] 1)
if len(dp_list[i]) <= len(dp_list[j]):
dp_list[i] = dp_list[j] [nums[i]]
print(dp_list[dp.index(max(dp))])
return dp_list
And I get this result:
[1, 2, 3]
But I wan something like this as result
1 2 3
I have tried using this, but the result still been the same
values = ''.join([str(i) for i in LIS(nums,n)])
CodePudding user response:
print(*dp_list[dp.index(max(dp))])