LeetCode p234 Palindrome Linked List 题解
1.题目:
Given a singly linked list, determine if it is a palindrome.
Follow up:
Could you do it in O(n) time and O(1) space?
题意:
判断一个单向链表是否回文
2.解题思路:
使用递归,再逆序匹配,也可以反转链表。
3.代码
1 |
|
很高兴遇见你~
Given a singly linked list, determine if it is a palindrome.
Follow up:
Could you do it in O(n) time and O(1) space?
题意:
判断一个单向链表是否回文
使用递归,再逆序匹配,也可以反转链表。
1 |
|