8ms C++ resolution


  • -1
    M
    int minDepth(TreeNode* root) {
        if(!root)return 0;
        int depl=minDepth(root->left)+1;
        int depr=minDepth(root->right)+1;
        if(depl==1)return depr;
        if(depr==1)return depl;
        return depl<depr?depl:depr;
    }

Log in to reply
 

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