Skip to content

Commit 15105c8

Browse files
committed
BST iterator
1 parent 1232309 commit 15105c8

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# Definition for a binary tree node.
2+
# class TreeNode
3+
# attr_accessor :val, :left, :right
4+
# def initialize(val)
5+
# @val = val
6+
# @left, @right = nil, nil
7+
# end
8+
# end
9+
10+
class BSTIterator
11+
# @param {TreeNode} root
12+
def initialize(root)
13+
14+
end
15+
16+
# @return {Boolean}
17+
def has_next
18+
19+
end
20+
21+
# @return {Integer}
22+
def next
23+
24+
end
25+
end
26+
27+
# Your BSTIterator will be called like this:
28+
# i, v = BSTIterator.new(root), []
29+
# while i.has_next()
30+
# v << i.next
31+
# end

0 commit comments

Comments
 (0)