878. Find Minimum in BST

EasyTreesBSTTraversal

Given the root of a non-empty binary search tree, return the minimum key — the value found by following left 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 minimum key (or -1 if empty).

Examples

Example 1
Input: [8,3,10,1,6,null,14]
Output: 1
Explanation: Leftmost node holds the minimum.
Example 2
Input: [5]
Output: 5
Explanation: Single node.
Example 3
Input: [2,1,3]
Output: 1
Explanation: Leftmost is 1.

Constraints

Asked by

TCSInfosysWiproCognizantCapgemini
Solve this problem in the editor →