O39
Binary Tree Zigzag Level Order Traversal
Problem Statement & Objective
Given the root of a binary tree, return the zigzag level order traversal of its nodes' values (alternating left-to-right and right-to-left).
Function Signature (Python)
binary_tree_zigzag_level_order(root: list) -> list[list[int]]Input & Output Contract
Output Rule:Zigzag sırada katmanlar listesi.
System Constraints
0 <= agac.length <= 2000
-1000 <= agac[i] <= 1000Example Execution Walkthrough
agac = [3, 9, 20, None, None, 15, 7]
1. kat: [3]
2. kat: [20, 9] (sağdan sola)
3. kat: [15, 7] (soldan sağa)
cevap: [[3], [20, 9], [15, 7]]Example Test Scenarios (3)
Example 1
Input:
[[3,9,20,null,null,15,7]]Expected Output:
[[3],[20,9],[15,7]]Example 2
Input:
[[1]]Expected Output:
[[1]]Example 3
Input:
[[]]Expected Output:
[]