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.
int minDepth(TreeNode *root) { if (root == NULL) return 0; int left_minimum = minDepth(root->left); int right_minimum = minDepth(root->right); if (left_minimum == 0 || right_minimum == 0) return max(left_minimum, right_minimum) + 1; return min(left_minimum, right_minimum) + 1; }