how to take the nth linked list from input and print all nth linked list because each one has different roots
suppose
input:
3 // n
10 30 50 // linked list 1
1 5 6 // linked list 2
11 34 45 // 3rd
output :
print all these as it is
Taking input from user in linked list?
@rohitkandpal683 you can make a while loop and make it run n times and make all the declarations inside that while loop so that a new list is made for each iteration.
for eg you can do something like
int n;
cin >> n;
while (n–) {
//declare root, take input, print output, etc
}
if 2 linked list are given at a time then ho do i print it ,like a question merge 2 sorted linked list.
@rohitkandpal683 just initialise your head pointers with NULL and it will work okay. Otherwise, they might have some garbage values and will result in unexpected output.