Why i can AC in Binary Tree Level Order Traversal but get RE in Binary Tree Level Order Traversal 2


  • 0
    J

    Definition for a binary tree node.

    class TreeNode:

    def init(self, x):

    self.val = x

    self.left = None

    self.right = None

    class Solution:
    # @param {TreeNode} root
    # @return {integer[][]}
    def levelOrder(self, root):
    res,next = [],[]
    if root:
    temp = [root]
    else:
    return res
    res.append(temp)
    while 1:
    for v in temp:
    if v.left:
    next.append(v.left)
    if v.right:
    next.append(v.right)
    if not next:
    break
    res.append(next)
    temp = next
    next= []
    q=[[v.val for v in x] for x in res]
    return q[::-1]

    i get Line 42: AttributeError: Solution instance has no attribute 'levelOrderBottom'


Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.