Help in this program

can you help me to write the code or tell me the approach of this problem.

Hey @sid_kapoor
Follow this : Increasing Decreasing Sequence