想法都对了但是没写明白,不能把left和right分开看
//最后一个节点是根节点,从开始找第一个大于根的是右子树起始, //划分左右子树递归进行判断,如果左有大于根的或者右有小于根的,false class Solution { public boolean verifyPostorder(int[] postorder) { if(postorder==null||postorder.length<=1){ return true; } int len=postorder.length; return helper(postorder,0,len-1); } public boolean helper(int []postorder,int start,int end){ if(start>=end){ return true; } int root=postorder[end]; int i=start; while(postorder[i]<root)i++; int mid=i; for(int j=mid;j<end;j++){ if(postorder[j]<root){ return false; } } return helper(postorder,start,mid-1)&&helper(postorder,mid,end-1); } }