【树】最小数目深度 Posted on 2019-02-08 Edited on 2021-01-31 In 算法 Views: 题目描述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. 解题思路12345678910111213int run(TreeNode *root) { if(root==nullptr) return 0; if(root->left==nullptr&&root->right==nullptr) return 1; if(root->left==nullptr&&root->right!=nullptr) return run(root->right)+1; if(root->left!=nullptr&&root->right==nullptr) return run(root->left)+1; int l=1,r=1; l+=run(root->left); r+=run(root->right); return l<r?l:r; }