rightside
to store the visible nodes.levelLength
).
b. Iterate over all nodes in the current level.
c. For each node, remove it from the queue.
d. If it's the last node in the current level, add its value to rightside
.
e. Add the node's left and right children to the queue if they exist.rightside
.