Palindrome Linked List

Ru error in testcase 1

Your code will give run error if the number of elements in linked-list is even. Your while loop condition is

while(this.size!=1)

But in case of even number of elements, the size will become zero as you remove 2 elements at a time and your loop will still run, giving an error. What you can do is, before starting your loop, check if the size of linked list is odd or even. Take a variable n, and keep n=1 if LL size is odd and n=0 if is LL size is even. Now your while loop will run like this :

while(this.size!=n)

I hope this is clear, if not then let me know!