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

面试68题答案错误 #78

Open
astronaut0131 opened this issue Mar 25, 2020 · 0 comments
Open

面试68题答案错误 #78

astronaut0131 opened this issue Mar 25, 2020 · 0 comments

Comments

@astronaut0131
Copy link

astronaut0131 commented Mar 25, 2020

将test1改为
Test("Test1", pNode1, pNode1, pNode3, pNode1);
也就是

// 形状普通的树
//              1
//            /   \
//           2     3
//       /       \
//      4         5
//     / \      / |  \
//    6   7    8  9  10

1结点和3结点的最近公共祖先应该为1结点
得到
Failed.

这是因为GetNodePath并没有把target结点也存入,导致target结点为root时返回空list,从而导致后续代码出错
解决办法是GetNodePath总是要把target结点也加入

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