message: Added the problem and solution to check if a linked list if palindrome
diff: #include<bits/stdc++.h>
  using namespace std;
  +//Defining the structure
  struct Node{
  int data;
  struct Node *next;
  @@ -24,9 +25,10 @@ int main()
  struct Node *head=NULL, *tail=NULL;
  cin>>n;
  cin>>firstdata;
  - head=new Node(firstdata);
  + head=new Node(firstdata);//Creating a new node
  tail=head;
  + //Inserting the new node into the linked list
  for(i=1;i<n;i++)
  {
  @@ -43,14 +45,15 @@ int main()
  void reverse(struct Node**);
  bool compareLists(struct Node*, struct Node*);
  -bool isPalindrome(Node *head)
  +
  +bool isPalindrome(Node *head)//Function to check if linked list is palindrome
  {
  - //Your code here
  struct Node *slow_ptr = head, *fast_ptr = head;
  struct Node *second_half, *prev_of_slow_ptr = head;
  - struct Node* midnode = NULL; // To handle odd size list
  - bool res = true; // initialize result
  + struct Node* midnode = NULL;
  + bool res = true; // initialize result to true
  + //Finding the mid point of the linked list using 2 pointers
  if (head != NULL && head->next != NULL) {
  while (fast_ptr != NULL && fast_ptr->next != NULL) {
  @@ -66,11 +69,11 @@ bool isPalindrome(Node *head)
  }
  second_half = slow_ptr;
  - prev_of_slow_ptr->next = NULL; // NULL terminate first half
  - reverse(&second_half); // Reverse the second half
  - res = compareLists(head, second_half); // compare
  + prev_of_slow_ptr->next = NULL; // First half of the linked list terminated to NULL
  + reverse(&second_half); // Reverse the second half of the linked list
  + res = compareLists(head, second_half); // compare the first half and the second half of the linked list to see if they are equal or not
  - reverse(&second_half); // Reverse the second half again
  + reverse(&second_half); // Reverse the second half again to bring back the original linked list
  if (midnode != NULL) {
  prev_of_slow_ptr->next = midnode;
  @@ -82,11 +85,14 @@ bool isPalindrome(Node *head)
  return res;
  }
  +//Reversing the second half of the linked list
  void reverse(struct Node** head_ref)
  {
  struct Node* prev = NULL;
  struct Node* current = *head_ref;
  struct Node* next;
  +
  + //Run a loop for reversing the linked list
  while (current != NULL) {
  next = current->next;
  current->next = prev;
  @@ -96,23 +102,26 @@ void reverse(struct Node** head_ref)
  *head_ref = prev;
  }
  +//Comparing the first and the second half of the linked list
  bool compareLists(struct Node* head1, struct Node* head2)
  {
  + //Initializing 2 pointers pointing to the 2 heads of each linked list
  struct Node* temp1 = head1;
  struct Node* temp2 = head2;
  + //Comparing the data of the 2 linked list one by one to check if they are equal
  while (temp1 && temp2) {
  if (temp1->data == temp2->data) {
  temp1 = temp1->next;
  temp2 = temp2->next;
  }
  else
  - return 0;
  + return 0;//Return 0 if the corresponding data of both the linked list are not equal
  }
  if (temp1 == NULL && temp2 == NULL)
  - return 1;
  + return 1;//Return 1 if both the linked list are equal
  - return 0;
  + return 0; //Return 0 if either of the linked list is not NULL
  }
  