You just need to know English to understand this code and nothing else.......🥰
Intuition\nThe intuition behind this code is simple that is to perform DFS of the binary tree and keep track of the sum of each level. Then, find the level with
# Intuition\nThe intuition behind this code is simple that is to perform DFS of the binary tree and keep track of the sum of each level. Then, find the level with the maximum sum and return its index.\n\n# Approach\nJust jump to code there is no Rocket Science.\n\n# Complexity\n- Time complexity:\n```O(n)```\n\n- Space complexity:\n```O(n)```\n\n# Code\n```\nclass Solution {\npublic:\n    // Recursive function to perform level order traversal and compute level sums\n    void dfs(TreeNode* root, int level, vector<int> &sum) {\n        if (!root) return; // Base case: If root is null, return\n        if (level == sum.size()) {\n            sum.push_back(root->val); // If level is equal to the size of the sum vector, push current value into sum vector\n        } else {\n            sum[level] += root->val; // If level already exists in sum vector, add current value to the existing sum\n        }\n        dfs(root->left, level + 1, sum); // Recursively call dfs for the left child\n        dfs(root->right, level + 1, sum); // Recursively call dfs for the right child\n    }\n\n    // Function to find the level with the maximum sum\n    int maxLevelSum(TreeNode* root) {\n        vector<int> sum; // Vector to store the sum of each level\n        dfs(root, 0, sum); // Perform dfs and compute level sums\n\n        pair<int,int> res = {-1, INT_MIN}; // Pair to track the level with maximum sum\n\n        // Iterate through the sum vector to find the level with maximum sum\n        for (int i = 0; i < sum.size(); ++i) {\n            if (sum[i] > res.second) {\n                res = {i, sum[i]}; // Update res with the index of the level and its corresponding sum if a higher sum is found\n            }\n        }\n        \n        return res.first + 1; // Return the index(since it is 1-indexed(so +1)) of the level with the maximum sum \n        // last step -> upvote\n    }\n};\n\n```
['Recursion', 'Binary Tree', 'C++']