Here is my code:
What is missing in this?
Here is my code:
What is missing in this?
According to the question, the following possibilities may arise after splitting a sequence into two sequences:
-First Sequence is strictly decreasing , 2nd sequence is strictly increasing–> return true
-First Sequence is strictly increasing, 2nd sequence strictly decreases-------> return false
-If one sequence is empty and the other sequence is strictly increasing/decreasing—>return true.
Consider test case:
For input:
6
3
2
1
1
2
3
Now this splits into 2 sequences-- 3 2 1(decreasing) and 1 2 3(increasing)
So Expected Output:
true
In the sample input of the problem it gives 5 1 2 3 4 5 is true .
How can i split into two sequence increasing and decreasing ?
You don’t actually have to split. You can check the above conditions using some conditions with while loop. Try to think of a solution keeping in mind the above cases.