From 1811c2ed93df02fdc77a1dcdaa55c2f544e59700 Mon Sep 17 00:00:00 2001 From: ayush292003 <74094464+ayush292003@users.noreply.github.com> Date: Sun, 23 Oct 2022 11:14:13 +0530 Subject: [PATCH] Create populating next --- populating next | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 populating next diff --git a/populating next b/populating next new file mode 100644 index 0000000..5af708f --- /dev/null +++ b/populating next @@ -0,0 +1,26 @@ +class Solution: + def connect(self,root): + node=root + while(root): + + childhead=None + child=None + while(root): + if root.left: + if childhead is None: + childhead=root.left + child=root.left + else: + child.next=root.left + child=child.next + if root.right: + if childhead is None: + childhead=root.right + child=root.right + else: + child.next=root.right + child=child.next + root=root.next + root=childhead + return node +