I need to solve this problem with DP and here is the problem: we have an array and we want to make a ascending sub array with maximum size with 2 conditions:
- We can just traverse the array one time from left to right.
- We have just two valid moves to make this sub array :
- We can ignore the next element in array in the traverse
- We can put the next element at the end or start of the array and that array must be in ascending order
for .e.g:
input : arr[ ] = {0 , 3 , 10 , 7 , 6 , 5 , 14}
output : 5
and the Sub array is {5 , 6, , 7 , 10 , 14}
The solution for this instance is, start with 10 and then put 7 in the left and 6 and 5 to the left then put 14 in the right of 10
It means we can extend the array by this conditions from left and right