Submission Detail

55 / 55 test cases passed.
Status:

Accepted

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

Accepted Solutions Runtime Distribution

10
15
20
25
30
35
40
45
50
55
2
4
6
8
python
You are here!
Your runtime beats 16.95 % of python submissions.
Runtime (ms)
Distribution (%)

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

Accepted Solutions Memory Distribution

15750
15500
15550
15600
15650
15700
15800
15850
15900
15950
16000
5
10
15
20
25
30
35
python
You are here!
Your memory usage beats 16.95 % of python submissions.
Memory (KB)
Distribution (%)

15750
15500
15550
15600
15650
15700
15800
15850
15900
15950
16000
10
20
30
Zoom area by dragging across this chart

Invite friends to challenge Populating Next Right Pointers in Each Node II


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
36
37
38
39
40
41
42
43
44
45
46
"""
# Definition for a Node.
class Node(object):
def __init__(self, val=0, left=None, right=None, next=None):
self.val = val
self.left = left
self.right = right
self.next = next
"""
class Solution(object):
def connect(self, root):
"""
:type root: Node
:rtype: Node
"""
queue = []
next_queue = []
lot = []
if (root == None):
return root
queue.append(root)
# level order traversal
while (len(queue) > 0):
level = []
for n in range(0,len(queue)):
if (queue[n].left != None):
next_queue.append(queue[n].left)
if (queue[n].right != None):
next_queue.append(queue[n].right)
level.append(queue[n])
lot.append(level)
queue = next_queue
next_queue = []
# set next nodes
for l in lot:
for n in range(0,len(l)):
if (n != len(l)-1):
l[n].next = l[n+1]
return root
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX