def test2(self):
     root = TreeNode(1)
     self.assertEqual([1], caller(root))
示例#2
0
 def dfs(left, right):
     if left > right: return None
     mid = (left + right) // 2
     return TreeNode(nums[mid], dfs(left, mid - 1), dfs(mid + 1, right))
 def test1(self):
     root = TreeNode(1)
     right = TreeNode(2)
     root.right = right
     right.left = TreeNode(3)
     self.assertEqual([1, 2, 3], caller(root))