dsa · easy

Binary Tree Left View

GreyOrangeTreeQueueFoundation

Return the values visible from the **left** (first node of each BFS level). Tree encoding: [val, left, right] or None.

Arguments

**Example:** [1, [2, [4, None, None], None], [3, None, None]][1, 2, 4].

Constraints

Number of nodes in [0, 10^4] Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.

Examples

Example 1

Input:
[1, [2, [4, None, None], None], [3, None, None]]

Expected:
[1,2,4]

Example 2

Input:
None

Expected:
[]

Open in the Dojo editor