What's wrong with my solution?It can work in gcc.


  • 0
    K

    int i = 0,j = 0,a = 0;
    int minDepth(struct TreeNode* root) {
    if(!root) return 0;
    i++;
    printf("%d\n",i);
    if(root->left == NULL && root->right == NULL){
    j++;
    if(j == 1) a = i;
    if(i < a) a = i;
    j=1;
    }
    minDepth(root->left);
    minDepth(root->right);
    return a;
    }


Log in to reply
 

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