Complete the code to initialize the queue with the root node.
queue := []*TreeNode[1]We start the BFS by adding the root node to the queue.
Complete the code to dequeue the first node from the queue.
node := queue[[1]] queue = queue[1:]
In Go slices, the first element is at index 0, so we dequeue from index 0.
Fix the error in the code to add the left child to the queue only if it exists.
if node.Left [1] nil { queue = append(queue, node.Left) }
We add the left child only if it is not nil (exists).
Fill both blanks to add the right child to the queue only if it exists and continue the loop.
if node.Right [1] nil { queue = append(queue, node.Right) } [2]
We add the right child if it is not nil, then continue to the next iteration.
Fill all three blanks to complete the BFS loop that processes nodes until the queue is empty.
for len(queue) [1] 0 { node := queue[[2]] queue = queue[[3]:] // process node }
The loop runs while queue length is greater than 0, dequeues from index 0, and slices from index 1 onward.
