wrong output
#include
using namespace std;
class node{
public:
int data;
node *next;
node(int d){
data = d;
next = NULL;
}
};
void insertAtTail(node *&head, int data){
if(head==NULL){
head= new node(data);
return;
}
node *tail = head;
while(tail->next!=NULL){
tail=tail->next;
}
tail->next=new node(data);
return;
}
void buildInput(node *&head){
int data;
cin>>data;
while(data!=-1){
insertAtTail(head,data);
cin>>data;
}
}
//racer technique
node *midPoint(node *head){
if(head==NULL || head->next==NULL){
return head;
}
node *slow =head;
node *fast = head->next;
while (fast!=NULL && fast->next==NULL){
fast=fast->next->next;
slow=slow->next;
}
return slow;
}
void print(node *head){
//node *temp=head;
while(head!=NULL){
cout<data;
head=head->next;
}
}
int main(){
node *head=NULL;
buildInput(head);
node *m= midPoint(head);
cout<data;
//print(head);
return 0;}