package leetcode
import (
"github.com/halfrost/LeetCode-Go/structures"
)
type TreeNode = structures.TreeNode
func minDepth(root *TreeNode) int {
if root == nil {
return 0
}
if root.Left == nil {
return minDepth(root.Right) + 1
}
if root.Right == nil {
return minDepth(root.Left) + 1
}
return min(minDepth(root.Left), minDepth(root.Right)) + 1
}
func min(a int, b int) int {
if a > b {
return b
}
return a
}