Increasing decreasing sequence

i am not able to spilt the sequence into two parts??how to write the correct code

Refer this implementation. Dry run it with the sample test case.