class Solution:
def binaryTreePaths(self, root: TreeNode) -> List[str]:
# edge case
if root == None:
return []
# regular case
path = ""
return self.helper(root, path)
def helper(self, root, path):
# stop condition
if root == None:
return []
if root.left == None and root.right == None:
return [path + str(root.val)]
# regular case
path = path + str(root.val) + "->"
return self.helper(root.left, path) + self.helper(root.right, path)