why my C++ code gets runtime error but runs well locally

  • 0

    class Solution {
    int* dfs(TreeNode* root){
    int row[2] = {0,0};
    return row;
    int* left = dfs(root->left);
    int* right = dfs(root->right);
    row[0] = left[1]+right[1];
    row[1] = max(left[0]+right[0]+root->val, left[1]+right[1]);
    return row;
    int rob(TreeNode* root) {
    return dfs(root)[1];

Log in to reply

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