标签:nod span else turn dea traversal code nbsp efi
mycode 98.56%
# Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = None # self.right = None class Solution(object): def levelOrder(self, root): """ :type root: TreeNode :rtype: List[List[int]] """ def deal(root,level): if not root: return if len(self.res) <= level: self.res.append([root.val]) else: self.res[level].append(root.val) deal(root.left,level+1) deal(root.right,level+1) self.res = [] deal(root,0) return self.res
leetcode-easy-trees-102. Binary Tree Level Order Traversal-YES
标签:nod span else turn dea traversal code nbsp efi
原文地址:https://www.cnblogs.com/rosyYY/p/11022475.html