From 7a2ba9dc1b7f086ccaffb4cf713042f676af1893 Mon Sep 17 00:00:00 2001 From: Angha Varanagaonkar <118808719+angha-varangaonkar@users.noreply.github.com> Date: Wed, 9 Oct 2024 18:09:27 +0530 Subject: [PATCH] Create potd_09_10_2024.java --- october_2024/potd_09_10_2024.java | 83 +++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 october_2024/potd_09_10_2024.java diff --git a/october_2024/potd_09_10_2024.java b/october_2024/potd_09_10_2024.java new file mode 100644 index 0000000..7c4d9e4 --- /dev/null +++ b/october_2024/potd_09_10_2024.java @@ -0,0 +1,83 @@ + + +// User function Template for Java + +/*class Node + +class Node +{ + int data; + Node right,down; + + Node(int data){ + this.data = data; + right = null; + down = null; + } +} +*/ +/*Function should return the head of the 2D LL.*/ +class Solution { + static Node head; + static Node construct(int arr[][]) { + // Add your code here. + int n=arr.length; + + if(n==1) + { + Node newnode =new Node(arr[0][0]); + head=newnode; + return head; + } + + Node newnode =new Node(arr[0][0]); + head=newnode; + + Node currnode=newnode; + Node firstnode=head; + Node secondnode=head; + + for(int i=0;i0) + { + + Node newnode3=new Node(arr[i][0]); + firstnode.down=newnode3; + + currnode=newnode3; + firstnode=firstnode.down; + + } + + + for(int j=1;j