Zigzag Level Order Traversal of Binary Tree
Given a binary tree, return the zigzag level order traversal of its nodes' values. (ie, from left to right, then right to left for the next level and alternate between).
For example:
Given binary tree [3,9,20,null,null,15,7],
3
/ \
9 20
/ \
15 7
return its zigzag level order traversal as:
[
[3],
[20,9],
[15,7]
]
Appr ...
Posted on Mon, 27 Jul 2026 16:05:55 +0000 by Hypnos
Binary Tree Traversal Techniques: Recursive and Iterative Approaches
Recusrive Traversal Patterns
Recursive implmeentations follow the core principle of processing the root node before/after children.
Preorder Trvaersal (Root-Left-Right)
class Solution {
public:
void processNode(TreeNode* current, std::vector<int>& output) {
if (!current) return;
output.push_back(current->val); ...
Posted on Mon, 25 May 2026 18:00:11 +0000 by Grizzzzzzzzzz