简历:The Google Resume: How to Prepare for a Career and Land a Job at Apple, Microsoft, Google, or any Top Tech Company
算法学习书籍:Introduction to Algorithms
编程珠玑:Programming Pearls (2nd Edition)
C++ 学习:The C++ Programming Language, 4th Edition
经典操作系统书籍,龙书:Operating System Concepts
创业:The Start-up of You: Adapt to the Future, Invest in Yourself, and Transform Your Career
Given a binary tree, return the level order traversal of its nodes' values. (ie, from left to right, level by level).
For example:
Given binary tree
Given binary tree
{3,9,20,#,#,15,7}
,3 / \ 9 20 / \ 15 7
return its level order traversal as:
[ [3], [9,20], [15,7] ]
confused what
» Solve this problem"{1,#,2,3}"
means? > read more on how binary tree is serialized on OJ.这题就是BFS,不论是图还是树的一种基本遍历的方法,应该掌握,比较简单,我用了2个queue来存,其实不需要,用一个count来计数每一层的node的个数,我使用了一个queue在level order traversal ii里面。
I always thought of using two queues or vectors. Never thought of using only one queue with simply counters. Grateful for being inspired by your blog. Thanks.
ReplyDelete