Solutions explained:
We can use a queue to help us keep track of the nodes of each level, before processing each level's nodes, we'll use a temp variable to hold the size of the current queue so that we know when to stop polling (next level).
After adding the current node's value into the list, we'll check if it has left and right children, we'll append them into the queue if there's any.
Time complexity: O(n)
Space complexity: O(n)