bst iterator
- binary search tree iterator ( in order ) follow up:两个BST,然后按顺序iterate。这个follow up建议大家一定不要想当然,要自己动手写一下,考虑齐全corn case,然后跑出来看看,里面有坑。。写173的人都应该已经有现成的iterator了吧 然后便利两个bst 就是用的两个这样的iterator 每次call next 比较大小 加上我原文中提到的trick就没问题了。。有一个比较巧妙的办法,用Integer 而不是int pointer记录每次iterate到的数字,如果发现Integer cur == null,再call next 赋值。
two bst iterator
原文:https://www.cnblogs.com/tobeabetterpig/p/9450636.html