using System.Collections.Generic;
public ListNode(int x) {this.val = x; this.next = null;}
public static void Main()
var list = new ListNode(2);
last.next = new ListNode(2);
last.next = new ListNode(1);
Console.WriteLine(IsPalindrome(list));
public static int IsPalindrome(ListNode list)
throw new Exception("List is empty");
var stack = new Stack<int>();
var stackVal = stack.Pop();