标签:
基本二叉树遍历
代码:
1 int minDepth(TreeNode *root) { 2 if (!root) 3 return 0; 4 5 int l = root->left ? minDepth(root->left) : 0; 6 int r = root->right ? minDepth(root->right) : 0; 7 8 return l * r > 0 ? min(l, r) + 1 : max(l, r) + 1; 9 }
Leetcode#111 Minimum Depth of Binary Tree
标签:
原文地址:http://www.cnblogs.com/boring09/p/4267439.html