标签:follow output could rom 相同 input ace NPU 部分
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)定义快慢指针得到链表的中点 (2)将后半部分逆序 (3)从头节点和中点开始比较是否相同
标签:follow output could rom 相同 input ace NPU 部分
原文地址:https://www.cnblogs.com/clarencezzh/p/10957034.html