Submission Detail

35 / 35 test cases passed.
Status:

Accepted

Runtime: 25 ms
Memory Usage: 14.4 MB
Submitted: 0 minutes ago
loading
Runtime Error Message:
Last executed input:
Input:
Output:
Expected:

Accepted Solutions Runtime Distribution

0
5
10
15
20
25
30
35
40
45
2.5
5.0
7.5
10.0
12.5
python
You are here!
Your runtime beats 52.14 % of python submissions.
Runtime (ms)
Distribution (%)

0
5
10
15
20
25
30
35
40
45
5
10
Zoom area by dragging across this chart

Accepted Solutions Memory Distribution

13500
13750
14000
14250
14500
14750
15000
15250
15500
15750
5
10
15
20
25
30
python
You are here!
Your memory usage beats 16.07 % of python submissions.
Memory (KB)
Distribution (%)

13500
13750
14000
14250
14500
14750
15000
15250
15500
15750
10
20
30
Zoom area by dragging across this chart

Invite friends to challenge Binary Tree Level Order Traversal


Submitted Code: 0 minutes ago

Language: python

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution(object):
def levelOrder(self, root):
"""
:type root: TreeNode
:rtype: List[List[int]]
"""
queue = []
next_queue = []
lot = []
if (root == None):
return lot
queue.append(root)
while (len(queue) > 0):
level = []
for n in queue:
if (n.left != None):
next_queue.append(n.left)
if (n.right != None):
next_queue.append(n.right)
level.append(n.val)
lot.append(level)
queue = next_queue
next_queue = []
return lot
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX