my code is showing run time error while running what is the problem.
my code------
#include
using namespace std;
class node
{
public:
int data;
node* next;
//constructor
node(int d){
data=d;
next=NULL;
}
};
void insertAtTail(node*&head,int data){
if(head==NULL){
head=new node(data);
return;
}
node* temp=head;
while(temp->next!=NULL){
temp=temp->next;
}
temp->next=new node(data);
return;
}
void buildlist(node*& head,int n){
int data;
cin>>data;
while(n–)
{
insertAtTail(head,data);
cin>>data;
}
}
int intersect_point(node* a,node* b){
if(a == NULL || b == NULL){
return -1;
}
if(a->data>b->data){
return intersect_point(a,b->next);
}
else{
return intersect_point(a->next,b);
}
}
int main() {
int n1;
cin>>n1;
node* a=NULL;
buildlist(a,n1);
node* b;
int n2;
cin>>n2;
buildlist(b,n2);
cout<<intersect_point(a,b)<<endl;
return 0;
}