Problem 1586 · Medium

Binary Search Tree Iterator II

Step through the sorted values of a binary search tree with a cursor that begins before the smallest value. Support moving forward, moving backward, and asking whether a move in either direction is available.

Open the interactive visualisation