1 Line c++ solution


  • 0
    D
    class Solution {
    public:
        int minDepth(TreeNode* root) {
            return root == NULL ? 0 : root->left == NULL ? 1 + minDepth(root->right) : root->right == NULL ? 1 + minDepth(root->left) : min(1+minDepth(root->left), 1+minDepth(root->right));
        }
    };
    

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.