Min Li's Note
KVM,QEMU, X86 virtualization
Pages
Home
Collection
About
Sunday, December 7, 2014
Binary Tree Zigzag Level Order Traversal
Problem
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:
Idea
用两个栈实现,依次往s1,s2插入,一个先插左子树再右子树,一个先插右子树再左子树,最后就能得到zigzag的遍历效果
Solution
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment