Hello!

PROBLEM—

I am troubling understanding how the “dp” relation came.

I know there is “old editorial” for this problem but i can’t understand it.

I checked other people solutions and they are doing differently.

Can someone explain me this dp relation origin?

```
for(int i = n - 1; i > 0; i--){
if(arr[i] <= arr[i + 1]){ // If arr[i] shows length of largest UD starting from arr[i]
dp[i][0] = dp[i + 1][1] + 1;
}
if(arr[i] >= arr[i + 1]){ // If arr[i] shows length of largest DU starting from arr[i]
dp[i][1] = dp[i + 1][0] + 1;
}
}
```