I think there is a VERY BIG hole in this question


  • 3
    G

    When I checked some others solutions committed and passed, I found that, they all miss the checking step,which means we need to check if there are both p and q in this tree.

    for example,there is a question name called Share C++/C# 24ms recursive solution , the solution it shows doesn't check wether TreeNode p and TreeNode q exist when it returns.

    So what do you guys think??


  • 2
    F

    If TreeNode p or q can not be found in the tree, then the result should be NULL which means LCA of p and q doesn't exist. But this case doesn't be tested in current test cases, I suppose.


  • 0
    S

    Also the meaning of "lowest" is not validated in the test case.

    for example, for tree [1,1,null,2,3], the LCA for 1, 2 is the root->left.


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.