104. Maximum Depth of Binary Tree

 int maxDepth(TreeNode* root) {

        if(!root) return 0;
        int maxLeft = maxDepth(root->left);
        int maxRight = maxDepth(root->right);
        return max(maxLeft, maxRight)+1;
    }

Comments

Popular posts from this blog

141. Linked List Cycle

67. Add Binary

88. Merge Sorted Array