# 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 levelOrderBottom(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
answ, L = [], [root]
while L and root:
answ.insert(0,[n.val for n in L])
L = [ C for N in L for C in (N.left,N.right) if C ]
return answ
Short python solution


@cygnx Not sure why this has up votes considering insert at 0 is O(n) operation. It would've made more sense to do the same the first level order problem and just reverse the answer...that would've been faster