I tried to solve this problem using HLD and Segment Tree. I didn't find LCA explicitly rather used HLD.
This solution gives runtime error. I can't find any reason for this kind of verdict.
I have already read this blog but couldn't understand why my code isn't working.
Can anyone help me?