def connect(self, root):
node=root
s=[node]
while True:
l=len(s)
if len(s)==0:
return root
while l>0:
curr=s.pop(0)
if l>1:
temp=s[0]
curr.next=temp
if l==1:
curr.next=None
if curr.left:
s.append(curr.left)
if curr.right:
s.append(curr.right)
l-=1
return None
Easy python solution, using level order traversal
ankit_bit
#1