''How to determine the longest increasing subsequence using dynamic programming?'' didn't help me enough that I could do it on my own so I am asking for your help.
I have a sequence of integers: (-2, 4, 1, 1, 5, -2, 3, 3, -1, 1)
. I want to find longest sequence of them according to these requirements using dynamic programming (X
here is a number, i
its index):
- The numbers have to go in order, their indexes would keep increasing
- If the index is an odd number, this requirement has to be met:
Xi <= Xi+1
, if the index is an even number, this requirement has to be met:Xi >= Xi+1
.
For example longest sequence would be: (-2, 4, 1, 5, -2, 3, -1, 1)
. Any help is greatly appreciated, I have been on this for the whole day..!