标签:== result get title turn 后序 一个 size int
class Solution { public: bool VerifySquenceOfBST(vector<int> sequence) { if(sequence.size() == 0){ return false; } int start = 0; int end = sequence.size()-1; bool flag = getResult(sequence, start, end); return flag; } bool getResult(vector<int> vt, int start, int end){ int i,j; if(end - start<=1){ return true; } for(i = start; i < end; i++){ if(vt[i]>vt[end]){ break; } } for(j = i; j < end; j++){ if(vt[j]<vt[end]){ return false; } } return getResult(vt,start,i-1)&&getResult(vt,i,end-1); } };
标签:== result get title turn 后序 一个 size int
原文地址:https://www.cnblogs.com/grglym/p/8992344.html