please explain , the basic concept to solve this problem.
How to solve this problem
Hello Rohit, this problem is just the variation of dp problem longest increasing subsequence. Here what we need to do is just calculate the increasing part for every state. As well as calculate the decreasing part for every state. And then for the particular index i add it’s decreasing as well increasing part and try to maximise that value.
Just try to think in that way, may be it will take time to understand the logic but try to think of dp and longest increasing subsequence for reference.
I hope it is clear to you. In case it is clear to you pls mark it as resolve and provide the rating as well as feedback so that we can improve ourselves.
In case there is still some confusion pls let me know, I will surely try to help you out.
Thanks 
Happy Coding !!
sorry, i don’t have the idea of dynamic programming. Any other algorithm?
Oh, but bro you need to understand DP. DP is very very important programming paradigm. Yes, it may be tricky or a little bit confusing too.
Talking about this ques specifically designed as DP problem. And we also expected dp answer from the students. But yes, you can also use segment trees or binary indexed trees for this but that would be too complex.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.