-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpalindrome.cs
More file actions
32 lines (28 loc) · 785 Bytes
/
Copy pathpalindrome.cs
File metadata and controls
32 lines (28 loc) · 785 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Palindrome
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine(IsPalindrome("test"));
}
public static bool IsPalindrome(string word)
{
//Split letters in list
List<char> charList = new List<char>();
charList.AddRange(word.ToLower());
//Check if first letter is the same with the last letter
for (int i = 0; i < charList.Count - 1 / 2; i++)
{
if (charList[i] != charList[charList.Count - i - 1])
return false;
}
return true;
}
}
}