Given the root of a binary search tree, return the sequence of values produced by an inorder iterator over the tree. Pattern focus: BST Iterator Thinking. The iterator exposes the BST in sorted order, so the output is the same as a full inorder traversal.
root = binary tree root
values returned by inorder iteration in order
Example 1:
Input:
root = [7,3,15,null,null,9,20]
Output:
[3,7,9,15,20]
Explanation:
The inorder iterator visits the BST in sorted order.
Example 2:
Input:
root = [2,1,3]
Output:
[1,2,3]
Explanation:
The iterator returns values from smallest to largest.