Golang solution (0ms)


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

Log in to reply
 

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