"""Definition of TreeNode:class TreeNode: def __init__(self, val): self.val = val self.left, self.right = None, None"""classSolution:""" @param root: The root of binary tree. @return: Level order in a list of lists of integers """deflevelOrder(self,root):# write your code hereq=[]q.append(root)result=[]ifroot==None:returnresultwhilelen(q)!=0:# size = num of nodes in each levelsize=len(q)row=[]foriinrange(size):node=q.pop(0)row.append(node.val)ifnode.left!=None:q.append(node.left)ifnode.right!=None:q.append(node.right)result.append(row)returnresult