what is time complexity of divide/conquer


  • 0
    N

    Hi, below is implementation of Divide and conquer . I can't figure out what is time complexity ? O(h)??

        int sumOfLeftLeaves(TreeNode* root) {
            if (root == NULL) {
                return 0;
            }
            
            int leaf = 0;
            if (root->left && !root->left->left && !root->left->right) {
                leaf = root->left->val;
            }
            
            return leaf + sumOfLeftLeaves(root->left) + sumOfLeftLeaves(root->right);
            
    
        }
    

Log in to reply
 

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