Python3 BFS solution


#1
def levelOrder(self, A):
    res = []
    
    queue = []
    queue.append(A)
    
    while queue:
        size = len(queue)
        temp = []
        for i in range(size):
            curr_node = queue[0]
            temp.append(curr_node.val)
            queue.pop(0)
            if curr_node.left:
                queue.append(curr_node.left)
            if curr_node.right:
                queue.append(curr_node.right)
        res.append(list(temp))
        
    return res