Skip to content

Conversation

@potrue
Copy link
Owner

@potrue potrue commented Aug 15, 2025

while (node) {
if (node->val <= target) {
*lesser_subtree_root_to_find = node;
TreeNode* tmp = node->right;

Choose a reason for hiding this comment

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

tmp は意味がある変数なので、next_node_to_split ぐらいでも良いかなと思いました。

vector<TreeNode*> splitBST(TreeNode* root, int target) {
TreeNode* lesser_root = nullptr;
TreeNode* greater_root = nullptr;
TreeNode** lesser_subtree_root_to_find = &lesser_root;

Choose a reason for hiding this comment

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

lesser_insert_position など node そのものではないことが変数名からわかると、L96 の操作の意味が読みやすいと思いました。

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