NeetCode #457LC-173MediumTrees
← Back to All Problems

#457 · #173 · Binary Search Tree Iterator(二叉搜索树迭代器)

📌 Problem Statement & Constraints

Implement a BSTIterator over the in-order traversal of a binary search tree, supporting next() (the next smallest value) and hasNext(). Both should run in O(1) average time and use O(h) memory. Constraints: the number of nodes is in [1, 10^5]; at most 10^5 calls.
🔒

Sign In to Unlock Full Solutions for All 973 Problems

Sign in to access step-by-step logic, benchmark Python3 code, complexity breakdown, and offline export!