Lowest common anscestor in binary tree

please provide the code as explained in the video,
and also for the case if a is present and b is not ,

here prateek sir assume that both a and b are present , but what if b is not present , please share the code link , REFER VIDEO( lowest common anscestor in binary tree)

Hey @shashank_sabharwal
Refer to https://ide.codingblocks.com/s/347424?_ga=2.213840020.1250786384.1610781386-1795954092.1597348154

Just add two booleans as well as tunr them to true if a/b are found
Then in main if any one of them is false then that means its not present

BUT the according to the method explained inthe video we were not checking that b is present or not for a particular case, in which prateek sir said we are just returning if a is present , then how to check in that case that is there is b or not

Keep two booleans say X and Y and keep them false
when u find a then mark X as true
when u find b tthen mark Y as true

So instead of this

if(root->data == a || root->data == b){
return root;
}
use

 if(root->data == a ){
        X=true;
        return root;
    }
  if( root->data == b){
    Y=true;
return root;
}

Now when u come back to main after callin lca function
if X & Y ==false then that means either a is absent or b is absent or both are absent