知识点:树
题目描述:
Given a binary tree, find its minimum depth.The minimum depth is the number of nodes along the shortest path from the root node down to the nearest leaf node.
思路1:递归解法
class Solution {
public:
int run(TreeNode *root) {
if (root==NULL)
return 0;
int n_left = run(root->left);
int n_right = run(root->right);
if (n_left==0||n_right==0)
return 1+n_left+n_right;
return n_left