Binary Tree Zigzag Level Order Traversal
Medium · Trees · about 15 minutes
Asked at Amazon, Bloomberg, Google, Microsoft, Meta, LinkedIn, Jane Street, Grammarly, Quora, Susquehanna (SIG).
Read a binary tree level by level, but switch direction each time: the top level left to right, the second right to left, the third left to right again, and so on. Return one list of values per level.