You are given the root of a Binary Search Tree (BST). Your task is to find and return the minimum value stored in the tree.
Return the smallest value present in the BST.
Input: root = [5,3,8,1,4,null,9]
Output: 1
Explanation: The leftmost node holds the smallest value, which is 1.
Input: root = [10,null,20]
Output: 10
Explanation: The root has no left subtree, so the root itself is the minimum.
Input: root = [42]
Output: 42
Explanation: A single-node BST has its minimum equal to the root value.
Approach, complexity and clean code in every language. Sign in to unlock the editorial.
Your submissions, results and runtime history live here. Sign in to start your streak.