Sponsored
Use these hints if you're stuck. Try solving on your own first.
Store the path from p to the root.
Traverse the path from q to the root, the first common point of the two paths is the LCA.
Solve with full IDE support and test cases