int Solution::solve(vector &a) {

```
stack<int> s;
int root = INT_MIN;
int n = a.size();
for(int i =0 ; i<n ;i++){
while(!s.empty()&&a[i]>s.top()){
root = s.top();
s.pop();
}
if(root>a[i])
return 0;
s.push(a[i]);
}
return 1;
```

}