Valid invalid sequence

need clues for solving this problem of c++ assignment

Consider the input:
5 (no.s in sequence)
1
2
3
4
5
A valid sequence is a sequence in which it can be broken into two sequences such that:

  1. First sequence is a strictly decreasing sequence (1) - single element can be taken either as a increasing or decreasing sequence.
  2. Later half of the sequence must be a strictly increasing sequence ( 2,3,4,5).

my code for valid invalid sequence is https://ide.codingblocks.com/#/s/15394.all test cases are not passing .need help.can you share the code.

Link of your code shows only default code. Can you share link of your code after properly saving it on ide of coding blocks

https://ide.codingblocks.com/#/s/15758
this is my code for valid invalid sequence problem.out of 10 test cases ,six are passing.

There are some mistakes in the logic that you are using.
According to your code you are extracting the last no (assuming it is a single digit,what if two digit nos are there in the array) of the sequence.
Suppose in an array with indices 0,…,n-1. There is one index in between say i.
Then for indices from 0 to i array elements should decrease strictly
and for indices i+1 to n-1 should increase strictly.
In this problem sequence of elements matters.
Dry run your code for input as
5
1
3
5
2
4
Just design your logic again.

the solution you are suggesting uses array .but in the problem statement it is mentioned not to use array or lists.kindly clarify on this.

Yes I just used array indices to explain the problem.
e.g. when you checked that up to ith no whether it forms an valid or invalid sequence then you just need the last element (ith no, to determine whether rest of sequence is valid or not) and need not to store the previous inputs

problem solved successfully.all test cases are passing now.thank you for the clue.