Golang recursive one line


  • 0
    M
    func isSameTree(p *TreeNode, q *TreeNode) bool {
    	return (p == nil && q == nil) || (p != nil && q != nil) && isSameTree(p.Left, q.Left) && isSameTree(p.Right, q.Right) && p.Val == q.Val
    }
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.