标签:false return tom nbsp and 后序 elf lse div
# -*- coding:utf-8 -*- class Solution: def VerifySquenceOfBST(self, sequence): # write code here if not sequence: return False root = sequence[-1] i = 0 while sequence[i] < root: i = i+ 1 for j in range(i,len(sequence)-1): if sequence[j] < root: return False left = sequence[:i] right =sequence[i:len(sequence)-1] leftIs = True rightIs =True if len(left) > 0: leftIs = self.VerifySquenceOfBST(left) if len(right) > 0: rightIs = self.VerifySquenceOfBST(right) return leftIs and rightIs
标签:false return tom nbsp and 后序 elf lse div
原文地址:https://www.cnblogs.com/tianqizhi/p/9726787.html