Python学习——leetcode(Binary Tree Level Order Traversal)
来源:互联网 发布:python import 和from 编辑:程序博客网 时间:2024/06/06 02:42
<pre name="code" class="python">class Solution: # @param root, a tree node # @return a list of lists of integers def levelOrder(self, root):queue=[]l=[]if root:queue.append(root)while len(queue)>0:length=len(queue)tempList=[]while length>0:tempNone=queue.pop()length-=1tempList.append(tempNone.val)if tempNone.left!=None:queue.insert(0,tempNone.left)if tempNone.right!=None:queue.insert(0,tempNone.right)l.append(tempList)return lelse:return l
0 0
- Python学习——leetcode(Binary Tree Level Order Traversal)
- Binary Tree Level Order Traversal Leetcode Python
- 【Leetcode】【python】Binary Tree Level Order Traversal
- LeetCode——Binary Tree Level Order Traversal
- LeetCode——Binary Tree Level Order Traversal II
- LeetCode——Binary Tree Level Order Traversal
- LeetCode——Binary Tree Level Order Traversal II
- leetcode——Binary Tree Level Order Traversal
- leetcode 102 —— Binary Tree Level Order Traversal
- leetcode 103 —— Binary Tree Zigzag Level Order Traversal
- leetcode 107 —— Binary Tree Level Order Traversal II
- Leetcode——107. Binary Tree Level Order Traversal II
- LeetCode——102. Binary Tree Level Order Traversal
- LeetCode102—Binary Tree Level Order Traversal
- LeetCode[Tree]: Binary Tree Level Order Traversal
- *(leetcode) Binary Tree Level Order Traversal (tree)
- [leetcode][tree] Binary Tree Level Order Traversal
- 【LeetCode with Python】 Binary Tree Level Order Traversal
- Jenkins进阶系列之——01使用email-ext替换Jenkins的默认邮件通知
- OC学习篇之---类目的概念和使用
- Emacs常用记录
- php注释标准
- 解决父页面加载iframe时,src链接中参数值过大导致加载失败的问题
- Python学习——leetcode(Binary Tree Level Order Traversal)
- C#中get与set方法
- 黑马程序员-多线程2
- sap 公司代码和工厂代码的关系
- OC学习篇之---类的延展
- C++primer plus第六版课后编程题答案18.1
- Jenkins进阶系列之——02email-ext邮件通知模板
- jsp链接数据库代码
- TCP连接探测中的Keepalive和心跳包