Skip to content

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

Copy link
Owner Author

Choose a reason for hiding this comment

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

減算しているので残りという概念のほうが適切ですね、ありがとうございます。

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のような「残り」を意味する変数名を使うという選択肢があると思います

Copy link
Owner Author

Choose a reason for hiding this comment

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

コメントありがとうございます。
たしかに、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.

4 participants