Code CPP
Code CPP
// linked lists
#include <bits/stdc++.h>
struct Node {
int data;
Node* next;
Node(int x) {
data = x;
next = nullptr;
};
if (head1 == nullptr)
return head2;
curr = curr->next;
curr->next = head2;
// Return the head of the concatenated list
return head1;
curr = curr->next;
int main() {
printList(concatHead);
return 0;