#include "s0111_minimum_depth_of_binary_tree.hpp" int S0111::minDepth(TreeNode* root) { if (root == nullptr) return 0; if (root->left == nullptr && root->right != nullptr) { return minDepth(root->right) + 1; } else if (root->left != nullptr && root->right == nullptr) { return minDepth(root->left) + 1; } else { return min(minDepth(root->left), minDepth(root->right)) + 1; } }