Skip to content

Instantly share code, notes, and snippets.

@ironpython2001
Created May 6, 2022 08:56
Show Gist options
  • Save ironpython2001/1b5d02526c0cccc750b63847710b4116 to your computer and use it in GitHub Desktop.
Save ironpython2001/1b5d02526c0cccc750b63847710b4116 to your computer and use it in GitHub Desktop.
palindrome lists in c#
//Palindrome Lists
//Input Result
//[“One”, “Test”, “ – ”, “Test”, “One”] True
//[“Max”, “Mike”, “Mike”, “Max”] True
//[“Tim”, “Tom”, “Mike”, “Max”] False
//var lst = new List<string>() { "One", "Test", "–", "Test", "One" };
var lst = new List<string>() { "Max", "Mike", "Mike", "Max"};
var cnt = lst.Count()/2;
var res1 = lst.Take(cnt);
var res2 = lst.TakeLast(cnt).Reverse();
Console.WriteLine(res1.SequenceEqual(res2));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment