判断链表的回文结构 题目判断一个链表的回文结构思路1回文结构是正序和逆序都相等的结构。2我们可以把整个链表逆置过来然后和原链表对比。3如果链表的结点是奇数个可以找到它的中间结点逆置前半段和后半段进行比较。4如果链表的结点是偶数个它的中间结点必为最中间的俩个的后一个那我们将后半段逆置和原链表的头结点开始比较。我们用第三种利用快慢指针找中间结点public static Node getMid(Node head){ Node fast head; Node slow head; while(fast ! null){ fast fast.next; if(fast null){ break; } slow slow.next; fast fast.next; } return slow; }逆置链表public static Node reverseList(Node head){ Node result null; Node cur head; while(cur ! null){ Node next cur.next; cur.next result; result cur; cur next; } return result; }判断是否为回文public static boolean chkPlalindrome(Node head){ Node mid getMid(head); Node newHead reverseList(mid); Node cur1 head; Node cur2 newHead; while(cur1 ! null cur2 ! null){ if(cur1.val ! cur2.val){ return false; } cur1 cur1.next; cur2 cur2.next; } return true; }完整程序https://github.com/WangWenQian12/Java_Practice/blob/master/JavaSE/IDEA/LinkedList/Review/ChkPlalindrome/src/ChkPlalin.java