标签:
public class Solution { public boolean VerifySquenceOfBST(int [] sequence) { int length=sequence.length; if(length==0) return false; int root=sequence[length-1]; int c=0; for(int i=0;i<length-1;i++){ if(sequence[i]>root){ c=i-1; if(c==0){ break; } } if(c!=0){ break; } } if(c!=0){ for(int i=0;i<=c;i++){ if(sequence[i]>root){ return false; } } for(int i=c+1;i<length-1;i++){ if(sequence[i]<root){ return false; } } } return true; } }
标签:
原文地址:http://blog.csdn.net/baidu_21578557/article/details/51636397