Tree107BinaryTreeLevelOrderTraversal2

来源:互联网 发布:sql stuff用法 编辑:程序博客网 时间:2024/06/05 00:59

9/24/2016第二遍写了,还是写了20min还想不起来recursive怎么写了

思路

  • BFS: Still write into the result list level by level, but use addFirst() to add them in to reverse the final result
  • Recursive DFS: 用了单独一个function来完成recursive. 其中忘记了逻辑漏洞

Logic Flaws

  • 同样错误第二次犯当在ResultList上直接改的时候,别忘记了如果那个item不存在,需要自己create,不能直接改哦。
0 0