Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Structure testing function num_decodings.py #866

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Eurus44
Copy link

@Eurus44 Eurus44 commented May 23, 2022

No description provided.

@aminulqrshah
Copy link

def binary_tree_paths(root):
    res = []
    if root is None:
        return res
    dfs(res, root, str(root.val))
    return res

def dfs(res, root, cur):
    if root.left is None and root.right is None:
        res.append(cur)
    if root.left:
        dfs(res, root.left, cur+'->'+str(root.left.val))
    if root.right:
        dfs(res, root.right, cur+'->'+str(root.right.val))@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants