#NEWLINE# def buildTree( self , inorder , postorder ) : #NEWLINE# #INDENT# '\n        Recursive algorithm. Pre-order, in-order, post-order traversal relationship\n\n        in-order:   [left_subtree, root,          right_subtree]\n        post-order: [left_subtree, right_subtree, root]\n\n        :param inorder: a list of integers\n        :param postorder: a list of integers\n        :return: TreeNode root\n        ' #NEWLINE# if ( not inorder ) : #NEWLINE# #INDENT# return None #NEWLINE# #UNINDENT# root = TreeNode ( postorder [ ( - 1 ) ] ) #NEWLINE# root_index = inorder . index ( root . val ) #NEWLINE# root . left = self . buildTree ( inorder [ : root_index ] , postorder [ : root_index ] ) #NEWLINE# root . right = self . buildTree ( inorder [ ( root_index + 1 ) : ] , postorder [ root_index : ( - 1 ) ] ) #NEWLINE# return root