Given the root of a binary tree, imagine yourself standing on the right side of it. Return the values of the nodes you can see ordered from top to bottom.
root = [1,2,3,null,5,null,4][1,3,4]root = [1,2,3,4,null,null,null,5][1,3,4,5]root == null return []; else offer root to queuesz = queue.size() — number of nodes at current leveli == sz-1 → add to result (rightmost!); enqueue non-null childrenBFS processes nodes left-to-right within each level. By capturing sz = queue.size() before the inner loop, we know exactly how many nodes belong to the current level. The node polled when i == sz - 1 is always the rightmost at that level — exactly what's visible from the right side. This is a simple one-line tweak on top of standard level-order BFS, with no extra data structures needed.