/** * Definition for singly-linked list. * public class ListNode { * public int val; * public ListNode next; * public ListNode(int x) { val = x; } * } */ public class Solution { public bool IsPalindrome(ListNode head) { if(head == null || head.next == null){ return true; } var list = new List(); while(head != null){ list.Add(head.val); head = head.next; } for(var i =0 ;i < list.Count/2; i++){ if(list[i] != list[list.Count-i-1]){ return false; } } return true; } }