Given a binary tree, find its minimum depth.The minimum depth is thenumber of nodes along the shortest path from the root node down to thenearest leaf node.
class Solution {
public:
int run(TreeNode *root) {
if(root==NULL)
return 0;
if(root->left==NULL)
return run(root->right)+1;
if(root->right==NULL)
return run(root->left)+1;
int left = run(root->left);
int right = run(root->right);
return left<right?left+1:right+1;
}
};