# leetcode104.二叉树的最大深度

```golang
/**
 * Definition for a binary tree node.
 * type TreeNode struct {
 *     Val int
 *     Left *TreeNode
 *     Right *TreeNode
 * }
 */
func maxDepth(root *TreeNode) int {
    if root==nil{
        return 0
    }
    var level int
    nodes:=make([]*TreeNode,0)
    nodes=append(nodes,root)

    for len(nodes)>0{
       level++
       currentNode:=make([]*TreeNode,len(nodes))
       currentNode=nodes[:]
       nodes=make([]*TreeNode,0)

       for _,node:= range currentNode{
           
           
           if node.Left!=nil{
               nodes=append(nodes,node.Left)
           }

           if node.Right!=nil{
               nodes=append(nodes,node.Right)
           }
       }

    }
    return level
}

```
