Lowest common ancestor(binary tree)

https://ide.geeksforgeeks.org/5CacF3mgFo
here why do we declare &path in the vector when it is a function argument.it is giving segmentation fault if I declare just path.

Hi @anitagupta1411
which ques are u referring to… if its for LCA then there is no need of maintaining the vectors… unnecessarily space complexity is being increased
and secondly &path is being used because we are passing by reference and applying backtracking (path.pop_back()) if u will pass without reference then it will give error only…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.