> For the complete documentation index, see [llms.txt](https://jaywin.gitbook.io/leetcode/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jaywin.gitbook.io/leetcode/topics/design.md).

# design

* `hasNext()` `next()` can be called independently
* for safety, call hasNext() before next()
* cant store all data in advance

<https://leetcode.com/problems/binary-search-tree-iterator> <https://leetcode.com/problems/flatten-nested-list-iterator> <https://leetcode.com/problems/peeking-iterator> <https://leetcode.com/problems/zigzag-iterator> <https://leetcode.com/problems/flatten-2d-vector> <https://leetcode.com/problems/design-compressed-string-iterator>
