public boolean chkPalindrome(ListNode A) {
if (this.head == null){
return false;
}else if (this.head.next == null){
return true;
}
Node fast = this.head;
Node slow = this.head;
while (fast.next != null && fast != null){
fast = fast.next.next;
slow = slow.next;
}
Node p =slow.next;
Node p1 = p.next;
while(p!=null){
p.next = slow;
slow = p;
p = p1;
if (p1 != null){
p1 = p1.next;
}
}
while(slow != head){
if (slow.data != this.head.data){
return false;
}
if (this.head.next == slow){
return true;
}
this.head=this.head.next;
slow = slow.next;
}
return true;
}