Created
May 6, 2022 08:56
-
-
Save ironpython2001/1b5d02526c0cccc750b63847710b4116 to your computer and use it in GitHub Desktop.
palindrome lists in c#
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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