Maximum Binary Tree
Medium
Divide and Conquer
Build a binary tree from an array of distinct integers: the root is the maximum value, the left subtree is built from the part before it and the right subtree from the part after it, recursively. Print the tree in level-order with null for gaps (omit trailing nulls).
Constraints
1 <= n <= 1000 0 <= nums[i] <= 1000
Discussion
No discussions yet.
Shalyam Support
Hi! Ask us anything — we'll reply on WhatsApp or Telegram within 24 hours.