class Solution: def levelOrder(self , root ): # write code here if not root:return [] queue = [root] res = [] while queue: res.append([node.val for node in queue]) temp = [] for node in queue: if node.left:temp.append(node.left) if node.right:temp.append(node.right) queue = temp return res