Help with error

prob: https://hack.codingblocks.com/app/contests/2022/416/problem

sol: https://ide.codingblocks.com/s/418360

approach: approach: store 2 paths from the root to the given nodes in 2 vectors traverse it and find the lowest common one

please tell the mistakes in my implementation

you are getting aborted error. see this
https://www.geeksforgeeks.org/core-dump-segmentation-fault-c-cpp/#:~:text=Core%20Dump%2FSegmentation%20fault%20is,an%20error%20indicating%20memory%20corruption.

Follow this approach:

  1. Start traversing the tree from the root node.
  2. If both the nodes p and q are in the right subtree, then continue the search with right subtree starting step 1.
  3. If both the nodes p and q are in the left subtree, then continue the search with left subtree starting step 1.
  4. If both step 2 and step 3 are not true, this means we have found the node which is common to node p’s and q’s subtrees. and hence we return this common node as the LCA.