题目描述
Given a singly linked list, determine if it is a palindrome.
Example 1:
Input: 1->2
Output: false
Example 2:
Input: 1->2->2->1
Output: true
Follow up:
Could you do it in O(n) time and O(1) space?
我的解法
实现代码
1 | /** |
Runtime: 16 ms, faster than 98.87% of C++ online submissions for Palindrome Linked List.
Memory Usage: 13.1 MB, less than 37.93% of C++ online submissions for Palindrome Linked List.