simple Solution with Dictionary
Intuition\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n Describe your approach to solving the problem. \n\n# Complexity\n- Time 
# Intuition\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity:\n    O(n) - we go through all elements of TreeNode\n\n- Space complexity:\n    O(n) - we have one Dictionary with all elements of TreeNode,\nthe length is O(2*n) = O(n)\n\n# Code\n```\n/**\n * Definition for a binary tree node.\n * public class TreeNode {\n *     public int val;\n *     public TreeNode left;\n *     public TreeNode right;\n *     public TreeNode(int val=0, TreeNode left=null, TreeNode right=null) {\n *         this.val = val;\n *         this.left = left;\n *         this.right = right;\n *     }\n * }\n */\npublic class Solution\n{\n    public int MaxLevelSum(TreeNode root)\n    {\n        Dictionary<int, int> dict = new Dictionary<int, int>();\n        Check(root, 1);\n        void Check(TreeNode root, int level)\n        {\n            if (root == null) return;\n            if (!dict.ContainsKey(level))\n                dict.Add(level, 0);\n            dict[level] += root.val;\n            Check(root.left, level + 1);\n            Check(root.right, level + 1);\n        }\n        return dict.MaxBy(x => x.Value).Key;\n    }\n}\n```
['C#']