The given test case

I think test case is wrong because 12345, there cannot be any two sequences in which s1 to si is dec. and si+1 to sN is incr.

In this ques 3 cases are valid:
Totally dec.
Totally inc.
Dec. then inc.

Make a solution keeping this in mind.

Hope this would help. If you still have doubts, feel free to ask.