def test1(self): root = TreeNode.build_from_layerorder( [4, 1, 6, 0, 2, 5, 7, None, None, None, 3, None, None, None, 8]) self.assertEqual([ 30, 36, 21, 36, 35, 26, 15, None, None, None, 33, None, None, None, 8 ], TreeNode.to_layerorder(self.bstToGst(root)))
def test3(self): s = TreeNode.build_from_layerorder([2]) t = TreeNode.build_from_layerorder([12]) self.assertEqual(False, self.isSubtree(s, t))
def test1(self): s = TreeNode.build_from_layerorder([3, 4, 5, 1, 2]) t = TreeNode.build_from_layerorder([4, 1, 2]) self.assertEqual(True, self.isSubtree(s, t))
def test2(self): s = TreeNode.build_from_layerorder( [3, 4, 5, 1, 2, None, None, None, 0]) t = TreeNode.build_from_layerorder([4, 1, 2]) self.assertEqual(False, self.isSubtree(s, t))
def test2(self): root = TreeNode.build_from_layerorder([-10,9,20,None,None,15,7]) self.assertEqual(42, self.maxPathSum(root))