*Sorry, Since it's a recursive algorithm, it uses O(N) space. Thanks for pointing out this.*

```
public class Solution {
public ListNode root;
public boolean isPalindrome(ListNode head) {
root = head;
return (head == null) ? true : _isPalindrome(head);
}
public boolean _isPalindrome(ListNode head) {
boolean flag = true;
if (head.next != null) {
flag = _isPalindrome(head.next);
}
if (flag && root.val == head.val) {
root = root.next;
return true;
}
return false;
}
```

}