Skip to content

112 path sum#25

Open
kitano-kazuki wants to merge 6 commits intomainfrom
112-path-sum
Open

112 path sum#25
kitano-kazuki wants to merge 6 commits intomainfrom
112-path-sum

Conversation

@kitano-kazuki
Copy link
Copy Markdown
Owner

@kitano-kazuki kitano-kazuki commented Mar 23, 2026

if node.left is not None:
node_to_visit.append((node.left, target_sum_at_this_node - node.val))
if node.right is not None:
node_to_visit.append((node.right, target_sum_at_this_node - node.val))
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

木探索は左の子からの探索が一般的ですが、stackを利用しているため、この順序を守りたい場合にはnode.rightを先にappendするのが良いと思いました

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.

2 participants