class Solution {
public boolean verifyPostorder(int[] postorder) {
return dfs(postorder,0,postorder.length-1);
}
public boolean dfs(int []postorder,int start,int root){
if(start>=root){
return true;
}
int m=start;
while(postorder[m]<postorder[root])m++;
int n=m;
while(postorder[m]>postorder[root])m++;
if(m==root){
return dfs(postorder,start,n-1)&& dfs(postorder,n,root-1);
}
else{
return false;//二叉搜索树后序遍历根节点前一个的节点一定是右节点并且大于他
}
}
}