You are given an array a of n integersnow, two functions f(x) and g(x) are definedf(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(1)), where 1sisnif such a number does not exist, for a particular index i, output 1 as its answerif such a number does exist, output:
a[g[fo]] inputthe first line contains a single integer n denoting the size of array aeach of the next n lines contains a single integer, where the integer on the ith line denotes a[i].
output:
print n space separated integers on a single line, where the ith integer denotes a[g[f]] or 1, if g[f]] does not existconstraints1

Answer :

Other Questions