234. Palindrome Linked List(迴文鏈表)

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 題目要求:以 O(1) 的空間複雜度來求解。 切成兩半,把後半段反轉,然後比較兩半是否相等。   時間複雜度:o(n) 
相關文章
相關標籤/搜索