int lowestCommonAncestor(struct TreeNode* root, int p, int q ) { // write code here int value; while(root!=NULL){ value=root->val; if(p==value||q==value) break; if(p>value&&q<value) break; if(p<value&&q>value) break; if(p>value&&q>value) root=root->right; if(p<value&&q<value) root=root->left; } return value; }