Spoj LCA problem

Can anyone help me find the bug in my code to this problem. Mine solution is here. You can uncomment the comments i have put in my code to debug.

I think u r unaware of how LCA will be calculated -

Learn from here -

  1. L03 : Lowest Common Ancestor | Part 1 - YouTube
  2. L04 : Lowest Common Ancestor - Part 2 | Binary Lifting - YouTube

Here is my solution