```
二叉搜索树中序遍历一定有序:后序 + 中序 建立二叉树
//二叉搜索树:中序遍历结果从小到大
class Solution {
public:
bool build(int pl, int pr, int il, int ir, vector[HTML_REMOVED] & postorder, vector[HTML_REMOVED] & inorder){
if(il > ir) return true;
int root = postorder[pr];
int k;
for(k = il; k <= ir; k ++)
if(inorder[k] == root) break;
if(k > ir) return false;
bool res = true;
if(!build( pl, pl + k - 1 - il, il, k - 1, postorder, inorder)) res = false;
if(!build( pr - 1 + k + 1 - ir, pr - 1, k + 1, ir, postorder, inorder)) res = false;
return res;
}
bool verifySequenceOfBST(vector<int> sequence) {
if(!sequence.size()) return true;
vector<int> inorder = sequence;
sort(inorder.begin(), inorder.end());
int n = sequence.size();
return build(0, n - 1, 0, n - 1, sequence, inorder);
}
};
···