https://leetcode-cn.com/problems/er-cha-sou-suo-shu-de-hou-xu-bian-li-xu-lie-lcof/solution/mian-shi-ti-33-er-cha-sou-suo-shu-de-hou-xu-bian-6/
法一:递归分治
//递归
class Solution {
public:
bool verifyPostorder(vector<int>& postorder) {
return recur(postorder,0,postorder.size()-1);
}
bool recur(vector<int>& postorder,int i,int j){
if(i>=j)return true;
int p=i;
while(postorder[p]<postorder[j])p++;
int m=p;
while(postorder[p]>postorder[j])p++;
return p==j&&recur(postorder,i,m-1)&&recur(postorder,m,j-1);
}
};