Skip to content

Commit 4e92e7e

Browse files
committed
173 accepted. 44ms
1 parent fa841d2 commit 4e92e7e

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package problem0173
22

3-
import "github.com/aQuaYi/LeetCode-in-Go/kit"
3+
import (
4+
"github.com/aQuaYi/LeetCode-in-Go/kit"
5+
)
46

57
// TreeNode is pre-defined...
68
/* Definition for a binary tree node.
@@ -42,6 +44,7 @@ func (it *BSTIterator) HasNext() bool {
4244

4345
func convert(root *TreeNode) []int {
4446
res := make([]int, 0, 128)
47+
helper(root, &res)
4548
return res
4649
}
4750

Algorithms/0173.binary-search-tree-iterator/binary-search-tree-iterator_test.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ func Test_BSTIterator(t *testing.T) {
1515
root := kit.Ints2TreeNode(ints)
1616

1717
it := Constructor(root)
18+
nums := kit.Tree2Inorder(root)
1819

1920
i := 0
2021

2122
for it.HasNext() {
22-
for ints[i] == kit.NULL {
23-
i++
24-
}
25-
ast.Equal(ints[i], it.Next(), "%d", ints[i])
23+
ast.Equal(nums[i], it.Next(), "%d", nums[i])
24+
i++
2625
}
2726
}

0 commit comments

Comments
 (0)