My LeetCode grinding. Trying to do a problem a day.
Du kan inte välja fler än 25 ämnen Ämnen måste starta med en bokstav eller siffra, kan innehålla bindestreck ('-') och vara max 35 tecken långa.

problem.txt 705B

12345678910111213141516171819202122232425
  1. Given an integer array with no duplicates. A maximum tree building on this array is defined as follow:
  2. The root is the maximum number in the array.
  3. The left subtree is the maximum tree constructed from left part subarray divided by the maximum number.
  4. The right subtree is the maximum tree constructed from right part subarray divided by the maximum number.
  5. Construct the maximum tree by the given array and output the root node of this tree.
  6. Example 1:
  7. Input: [3,2,1,6,0,5]
  8. Output: return the tree root node representing the following tree:
  9. 6
  10. / \
  11. 3 5
  12. \ /
  13. 2 0
  14. \
  15. 1
  16. Note:
  17. The size of the given array will be in the range [1,1000].