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

112. Path Sum #39

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

112. Path Sum #39

wants to merge 1 commit into from

Conversation

nodes_and_sums.pop();
if (!node) {
continue;
}
Copy link

Choose a reason for hiding this comment

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

sum -= node->val
先にしたほうが素直ではないですかね。どちらでもいいですが。あと、名前的には、sum というよりは残りですかね。
https://docs.google.com/document/d/11HV35ADPo9QxJOpJQ24FcZvtvioli770WWdZZDaLOfg/edit?tab=t.0#heading=h.ed3x3pkyeqkp

if (!node) {
continue;
}
if (!node->left && !node->right && sum == node->val) {
Copy link

Choose a reason for hiding this comment

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

sum == target_sumとなるかと思ったら違ったので少し戸惑いました。sumという変数名を使うなら足し上げていくか、odaさんも指摘されているようにcomplementやrest_sumのような「残り」を意味する変数名を使うという選択肢があると思います

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.

3 participants