Skip to content

Latest commit

 

History

History
44 lines (28 loc) · 801 Bytes

0103-binary-tree-zigzag-level-order-traversal.adoc

File metadata and controls

44 lines (28 loc) · 801 Bytes

103. Binary Tree Zigzag Level Order Traversal

思考题:思考一下如何使用深度优先来解决这个问题?

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]
]
link:{sourcedir}/_0103_BinaryTreeZigzagLevelOrderTraversal.java[role=include]