LeetCode – Palindrome Linked List (Java)
Given a singly linked list, determine if it is a palindrome. Java Solution 1 – Creat a new reversed list We can create a new list in reversed order and then compare each node. The time and space are O(n). public boolean isPalindrome(ListNode head) { if(head == null) return true; ListNode p = head; … Read more