03回文链表
回文链表
给你一个单链表的头节点 head ,请你判断该链表是否为回文链表。如果是,返回 true ;否则,返回 false 。
示例 1:

输入:head = [1,2,2,1]
输出:true提示:
- 链表中节点数目在范围
[1, 105]内 0 <= Node.val <= 9
public class ListNode {
int val;
ListNode next;
ListNode() {}
ListNode(int val) { this.val = val; }
ListNode(int val, ListNode next) { this.val = val; this.next = next; }
}
ListNode font;
public boolean isPalindrome(ListNode head) {
font = head;
return isPalindromeRecur(head);
}
private boolean isPalindromeRecur(ListNode node){
if(node==null){
return true;
}
if(!isPalindromeRecur(node.next)){
return false;
}
if(node.val != font.val){
return false;
}
font = font.next;
return true;
}03回文链表
https://jiajun.xyz/2026/02/07/算法/07链表/03回文链表/