Working with Graphs & Trees
What tree relationship is this algorithm finding?
function findLCA(root, p, q) {
if (!root || root === p || root === q) return root;
const left = findLCA(root.left, p, q);
const right = findLCA(root.right, p, q);
if (left && right) return root;
return left || right;
}