/**
* Definition for a binary tree node.
二叉树的节点定义
* struct TreeNode {
* int val;
* struct TreeNode *left;
* struct TreeNode *right;
* };
*/
struct TreeNode* lowestCommonAncestor(struct TreeNode* root, struct TreeNode* p, struct TreeNode* q) {
while((root->val - p->val) * (root->val - q->val) > 0)
root = p->val < root->val ? root->left : root->right;
return root;
}