class Solution {
public:
int minDepth(TreeNode *root) {
if(root == NULL)
return 0;
if(root -> left == NULL)
return minDepth(root -> right) + 1;
if(root -> right == NULL)
return minDepth(root -> left) + 1;
return min((minDepth(root -> left) + 1),(minDepth(root -> right) + 1));
}
};
[LeetCode] Minimum Depth of Binary Tree
最新推荐文章于 2019-10-10 21:42:22 发布