dsa · medium
Binary Search Tree Iterator
GreyOrangeTreeStackDesign
BSTIterator(root) then next / hasNext over **inorder**. Tree encoding [val,left,right].
Fill in the BSTIterator class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.
**Example**
`` BSTIterator([7,[3,null,null],[15,[9,null,null],[20,null,null]]]) → null next() → 3 next() → 7 hasNext() → true next() → 9 hasNext() → true ``
Constraints
Number of nodes <= 100
Examples
Example 1
Input: ["BSTIterator","next","next","hasNext","next","hasNext"] [[[7,[3,None,None],[15,[9,None,None],[20,None,None]]]],[],[],[],[],[]] Expected: [null,3,7,true,9,true]