@xcv58 Hi, I was wondering if my code would work as well

class BST() {

//I use a stack and in order traversal, so by the end of traversing through the //entire BST, stack has all values in order (descending order)

Stack<Integer> stack = new Stack<Integer>();

public BSTIterator(TrieNode root){

if(node==null) { return null;}

BSTIterator(root.left, stack);

stack.push(root.val);

BSTIterator(root.right,stack);}

public boolean hasNext(){

//Since stack is in descending order, as long as the stack is not empty, it //should satisfy the hasnext() requirement

return !stack.isEmpty();}

public int next(){

//since the stack is in descending order, simply pop the next smallest one

return stack.pop();}

I am new to this so I may have made some minor/major errors. Do let me know where my logic fails and why.

Thanks!