diff --git a/problems/0654.最大二叉树.md b/problems/0654.最大二叉树.md index 77d7980f..6b343840 100644 --- a/problems/0654.最大二叉树.md +++ b/problems/0654.最大二叉树.md @@ -582,6 +582,21 @@ impl Solution { } } ``` +### C# +```C# +public TreeNode ConstructMaximumBinaryTree(int[] nums) +{ + if (nums.Length == 0) return null; + int rootValue = nums.Max(); + TreeNode root = new TreeNode(rootValue); + int rootIndex = Array.IndexOf(nums, rootValue); + + root.left = ConstructMaximumBinaryTree(nums.Take(rootIndex).ToArray()); + root.right = ConstructMaximumBinaryTree(nums.Skip(rootIndex + 1).ToArray()); + return root; + +} +```