Given the root of a non-empty binary search tree, return the maximum key — the value found by following right children to the end. Return -1 for an empty tree. The tree is given as a level-order BST array.
Input: A level-order BST array.
Output: Integer — the maximum key (or -1 if empty).
Input: [8,3,10,1,6,null,14]
Output: 14
Explanation: Rightmost node holds the maximum.Input: [5]
Output: 5
Explanation: Single node.Input: [2,1,3]
Output: 3
Explanation: Rightmost is 3.0<=nodes<=10^4valid BST