专栏名称: 每日一道算法题
学习算法是一种信仰,每天都需要坚持!
目录
相关文章推荐
算法爱好者  ·  DeepSeek 下棋靠忽悠赢了 ... ·  1小时前  
九章算法  ·  Cruise被迫裁员50%!高额遣散费打脸科 ... ·  2 天前  
九章算法  ·  一年被裁两次,一个底层码农的大落大起 ·  2 天前  
算法爱好者  ·  为 DeepSeek 辟谣:五大误解与真相解读 ·  2 天前  
九章算法  ·  谷歌/亚麻的BQ题库,附上标准答案! ·  3 天前  
51好读  ›  专栏  ›  每日一道算法题

173. Binary Search Tree Iterator

每日一道算法题  · 公众号  · 算法  · 2017-06-04 00:26

正文

173. Binary Search Tree Iterator


Implement an iterator over a binary search tree (BST). Your iterator will be initialized with the root node of a BST.

Calling next() will return the next smallest number in the BST.

Note: next() and hasNext() should run in average O(1) time and uses O( h ) memory, where h is the height of the tree.

提示:提交代码后,需要用简洁的语言解释一下代码思路~ 谢谢

历史题目和总结见公众号「每日一道算法题」

https://leetcode.com/problems/binary-search-tree-iterator/#/description










请到「今天看啥」查看全文