Minimum and Maximum in BST
Easyjavapythonccppjavascript
Find the smallest and largest values stored in a Binary Search Tree.
Input Format
The first line contains an integer M. The second line contains M space-separated tokens (integers or null) — the BST in level order.
Output Format
Print two lines: Min = x Max = y
Example 1
Input
7 8 3 10 1 6 null 14
Output
Min = 1 Max = 14
Explanation: Follow left children for the minimum and right children for the maximum.
- 1 <= number of nodes <= 5000
- -1000000000 <= value <= 1000000000