234. 回文链表(java实现)–2种解法(双指针,反转链表后半段)LeetCode
文章目录
题目:解法1:双指针解法2:反转链表后半段01:递归02:不设置前驱节点03:设置前驱节点
题目:
解法1:双指针
/**
* 思路:
* 遍历链表值存入集合
* 双指针判断回文数
*/
public static boolean isPalindrome(ListNode head) {
ArrayList
while (head != null) {
list.add(head.val);
head = head.next;
}
return judge_doublePoint(list);
}
private sta
共有 0 条评论