Simple C solution


#1

int solve(int* A, int n1) {
int i;
int stack[n1];
int top = 0;
int head = -1;
for(i=1; i<n1; i++)
{
if(A[i]<=head)
return 0;
while(top>0 && stack[top-1]<A[i]){
head = stack[top-1];
top–;
}
stack[top++] = A[i];
}
return 1;
}