Pathetic question with wrong test case


#1

73 15 20 34 35 5 14 16 26 -1 25 23 -1 30 3 36 -1 -1 7 24 11 32 -1 -1 21 -1 -1 -1 29 4 9 -1 33 13 -1 -1 -1 -1 22 31 -1 27 19 1 -1 12 18 6 -1 -1 -1 2 -1 -1 -1 -1 10 -1 -1 -1 -1 8 -1 28 -1 -1 -1 -1 -1 17 -1 -1 -1 -1
33
5
answer should be 73 it gives 5 as answer.
only a predefined code is acceptable other codes give memory exceed, despite being of same complexity time wise and space wise.
Just pathetic IB shut down this timewasting shit .
bool help(TreeNode* root, int A, int B,int &ans){
if(root==NULL) return false;

 if(root->val==A || root->val==B) {
    ans = -2;
    return true;
 }
 bool l = help(root->left,A,B,ans);
 bool r = help(root->right,A,B,ans);
 if(l==true &&  r==true ){
     ans = (root->val);
     return true;
 }
 // else if(l==true && r==false) ans =-3;
 //else if(l==false && r==true) ans =-2;
 
 return l||r;

}
int Solution::lca(TreeNode* A, int B, int C) {
int ans =-5;

bool j = help(A,B,C,ans);
if(C==B && ans==-2 ) return C;
else if(C==B && ans==-1) return -1;

if(ans<0) return -1;
else return ans;

}