You are given an array A of Nintegers. Now,
two functions F(X) and G(X) are defined:
F(X): This is the smallest number Z such that
X < < < N and A[X] < A[Z]
G(X): This is the smallest number Z such that
X< Z < N and A[X] > A[Z]
Now, you need to find for each index i of this
array G(F(i)), where 1 <i<N. If such a
number does not exist, for a particular index i,
output 1 as its answer. If such a number does
exist, output A[G(F(i))]
Answers
Answered by
0
If such a number does exist, the output will be:
Explanation of input and output:
- A[G[FO]] Input:
The first line contains a single integer N representing the size of array A. - Every next N line contains a single integer, and every integer on the ith line denotes A[i].
Also, the output will be:
- Print N space-separated integers on one line; where the ith integer denotes A[G[F]] or 1 if G[F]] does not exist.
- Thus, Constraints: 1
Similar questions