int lowestCommonAncestor(struct TreeNode* root, int p, int q ) { // write code here int low = 0, high = 0; if (p > q) { low = q; high = p; } else { low = p; high = q; } if (low <= root->val && high >= root->val) { return root->val; } else if (high < root->val) { return lowestCommonAncestor(root->left, p, q); } else { return lowestCommonAncestor(root->right, p, q); } }