I had a doubt in the code i had written which differed a bit from the code sir has given.
IN the case where we are checking for LCA in which one node is ancestor of the other node and vice-versa instead of using the ternary operator i used the if block to implement the same logic.(I have commented out my logic in the code lines 275-279)
But it doesnt work same way.What is wrong in code?