标签:后序遍历序列 python seq += enc 搜索 title tle 判断
# -*- coding:utf-8 -*- class Solution: def isSquenceOfBST(self, sequence): if len(sequence)<=2: return True root =sequence[-1] index=0 res=True while index<len(sequence)-1 and sequence[index]<root: index+=1 mark=index while index<len(sequence)-1 and sequence[index]>root: index+=1 if index==len(sequence)-1: return self.isSquenceOfBST(sequence[:mark]) and self.isSquenceOfBST(sequence[mark:-1]) else: return False def VerifySquenceOfBST(self, sequence): # write code here if sequence==[]: return False else: return self.isSquenceOfBST(sequence)
标签:后序遍历序列 python seq += enc 搜索 title tle 判断
原文地址:https://www.cnblogs.com/hit-joseph/p/11916940.html