题目:https://leetcode.com/problems/binary-search-tree-iterator/
代码(github):https://github.com/illuz/leetcode
实现一个 BST 的类。
- (C++) 初始化的时候就将中序遍历处理好,保存在 queue 里
- (Python) 用 stack 做,一边求一边处理即可。
- Morris Travese Tree,可以用 O(1) 的空间解决这题,详见 099. Recover Binary Search Tree (Hard)