title: when i used fast=fast->next->next at line 4 code run properly, but shows runtime error when i used it in place of line 8 .why it happend
body: <pre><code>/**
   * Definition for singly-linked list.
   * struct ListNode {
   *     int val;
   *     struct ListNode *next;
   * };
   */
  
  
  bool isPalindrome(struct ListNode* head){
     if(head== NULL || head-&gt;next==NULL) return true;
      
      struct ListNode *curr=head,*prev=NULL,*next=head,*fast=head;
      while(fast &amp;&amp; fast-&gt;next){
          next=curr-&gt;next;
         // fast=fast-&gt;next-&gt;next;
          curr-&gt;next=prev;
          prev=curr;
          curr=next;
          fast=fast-&gt;next-&gt;next;
      }
      if(fast!=NULL &amp;&amp; fast-&gt;next==NULL) curr=curr-&gt;next;
      
      while(prev &amp;&amp; curr){
          if(prev-&gt;val!=curr-&gt;val) return false;
          prev=prev-&gt;next;
          curr=curr-&gt;next;
      }
      return true;
      
  }
  </code></pre>