Skip to content

Commit f56ed51

Browse files
committed
add test for problem 623
1 parent 4604294 commit f56ed51

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/problems/623.add-one-row-to-tree.jl

+2-2
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ function add_one_row!(root::TreeNode, val::Int, depth::Int)
9393
queue = [root]
9494
for _ in 1:(depth - 2), _ in eachindex(queue)
9595
node = popfirst!(queue)
96-
isnothing(node.left) || (push!(queue, node.left))
97-
isnothing(node.right) || (push!(queue, node.right))
96+
isnothing(node.left) || push!(queue, node.left)
97+
isnothing(node.right) || push!(queue, node.right)
9898
end
9999
for node in queue
100100
left, right = node.left, node.right

test/problems/623.add-one-row-to-tree.jl

+4
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,8 @@
99
add_one_row!(root, val, depth) ==
1010
TreeNode{Int}([4, 2, nothing, 1, 1, 3, nothing, nothing, 1])
1111
end
12+
@test begin
13+
root, val, depth = TreeNode{Int}([4, 2, 6, 3, 1, 5]), 1, 1
14+
add_one_row!(root, val, depth) == TreeNode{Int}([1, 4, nothing, 2, 6, 3, 1, 5])
15+
end
1216
end

0 commit comments

Comments
 (0)