求教一道经典面题的解法# JobHunting - 待字闺中
D*6
1 楼
print binary tree in level order, starting from the top, an alternate is
starting from the lowest level. Starting a new line for each level.
这题是不是就用个queue 加个 counter, count读到的node数量, print the new line
when counter gets to 1, 2, 4, 8, .....还有就是children是null也要加到
queue里去make sure counter behaves correct.
大家都是这么做的吗? 有啥其他的方法吗?
谢谢
starting from the lowest level. Starting a new line for each level.
这题是不是就用个queue 加个 counter, count读到的node数量, print the new line
when counter gets to 1, 2, 4, 8, .....还有就是children是null也要加到
queue里去make sure counter behaves correct.
大家都是这么做的吗? 有啥其他的方法吗?
谢谢