isListPalindrome
to determine if the list is a palindrome. A palindrome is a sequence that reads the same backward as forward.1->2->3->2->1 ==> true
1->2->2->3 ==> false
1 ==> true
null ==> true
ListNode
s of each as you iterate over them. The only drawback with this approach is that you'll be using O(n) space. We can actually solve this problem keeping constant space by reversing the second half of the list! Let's try that one.
ListNode
.
public Boolean isListPalindrome(ListNode head) { }
C
Java
Python