using System.Collections.Generic;
public static void Main()
LinkedListNode head = new LinkedListNode(1);
head.Next = new LinkedListNode(1);
head.Next.Next = new LinkedListNode(6);
head.Next.Next.Next = new LinkedListNode(6);
head.Next.Next.Next.Next = new LinkedListNode(1);
head.Next.Next.Next.Next.Next = new LinkedListNode(1);
Console.Write(current.Val);
var isPalindrome = ReverseAndCheck(head);
Console.WriteLine(isPalindrome);
private static bool ReverseAndCheck(LinkedListNode node){
var allValues = new List<int>();
StringBuilder simple = new StringBuilder();
allValues.Add(current.Val);
simple.Append(current.Val);
StringBuilder reversed = new StringBuilder();
for(var i = allValues.Count() - 1; i >= 0; i--){
reversed.Append(allValues[i]);
return simple.ToString() == reversed.ToString();
private static bool SolveUsingArray(LinkedListNode node){
var positionSums = new Dictionary<int, int>();
if(positionSums.ContainsKey(current.Val)){
positionSums[current.Val] = positionSums[current.Val] + length;
positionSums.Add(current.Val, length);
var sameValue = positionSums.ElementAt(0).Value;
for(int i = 1; i < positionSums.Count(); i++){
Console.WriteLine(positionSums.ElementAt(i).Value);
var isLLOddAndLastElement = (length % 2 == 1) && (i == length - 1);
if(positionSums.ElementAt(i).Value != sameValue && !isLLOddAndLastElement){
private static bool Initiate(LinkedListNode node){
if(current.Next == null){
if(current.Val == firstVal){
return Check(node.Next, length - 1);
static int currentlyAt = 1;
private static bool Check(LinkedListNode node, int till){
if(currentlyAt == length/2){
return current.Val == firstVal;
else if(current.Val == firstVal){
return Check(node.Next, till - 1 );
internal class LinkedListNode{
public LinkedListNode Next;
public LinkedListNode(int value){