Solving Binary Search Tree Iterator in go. Please try yourself first to solve the problem and submit your implementation to LeetCode before looking into solution.

Problem Description

Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.

Example:

BSTIterator iterator = new BSTIterator(root);
iterator.next();    // return 3
iterator.next();    // return 7
iterator.hasNext(); // return true
iterator.next();    // return 9
iterator.hasNext(); // return true
iterator.next();    // return 15
iterator.hasNext(); // return true
iterator.next();    // return 20
iterator.hasNext(); // return false

Note:

See the full details of the problem Binary Search Tree Iterator at LeetCode

Originally posted at: @github.com/halfrost/LeetCode-Go