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

0236.二叉树的最近公共祖先Rust版本代码的问题 #2728

Open
eliozh opened this issue Sep 11, 2024 · 0 comments
Open

0236.二叉树的最近公共祖先Rust版本代码的问题 #2728

eliozh opened this issue Sep 11, 2024 · 0 comments

Comments

@eliozh
Copy link

eliozh commented Sep 11, 2024

在判断 rootpq 的指针是否相等时,
原版代码直接使用 root == p || root == q,这样会导致递归地比较当前节点的 val 以及左右子节点的存在性以及 val 是否相等,影响性能,具体可以看: post.
应该使用 Rc::ptr_eq() 判断两个 Rc 的指针是否相等。

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

No branches or pull requests

1 participant