/**
* Definition for a binary tree node.
* type TreeNode struct {
* Val int
* Left *TreeNode
* Right *TreeNode
* }
*/funclowestCommonAncestor(root,p,q*TreeNode)*TreeNode{ifroot==nil{returnnil}ifroot.Val==p.Val||root.Val==q.Val{returnroot}left:=lowestCommonAncestor(root.Left,p,q)right:=lowestCommonAncestor(root.Right,p,q)ifleft!=nil&&right!=nil{returnroot}ifleft!=nil{returnleft}returnright}