Segmentation fault is coming

hello @vageesha

ur logic looks correct.
what input u r giving in input?

1 2 4 6 -1 -1 7 -1 -1 5 8 -1 -1 9 -1 -1 3 -1 -1
This was the input which I gave.

ur logic for lca is correct.

pls check ur code link once ,the code that have given is not even compiling

Sir, can u plz check this one. Again my answer is not coming.

check now->