Skip to content
This repository was archived by the owner on Sep 20, 2023. It is now read-only.

Commit 9bb380c

Browse files
committed
173 accepted. 44ms
1 parent ce28596 commit 9bb380c

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

+4-1
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

+3-4
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)