using a mock c# question on https://www.testdome.com/t
I have coded
using System;
public class Palindrome
{
public static bool IsPalindrome(string word)
{
string testWord = word;
string first = word[0].ToString();
string last = word[word.Length - 1].ToString();
bool isPal = false;
while (testWord.Length > 1)
{
Console.WriteLine(testWord);
if (first.ToLower() == last.ToLower())
{
testWord = testWord.Remove(0,1);
testWord = testWord.Remove(testWord.Length - 1);
isPal = true;
}
}
return isPal;
}
public static void Main(string[] args)
{
Console.WriteLine(Palindrome.IsPalindrome("Deleveled"));
}
}
this code is working but it is failing me on lowercase words: time limit exceeded various words: time limit exceeded.
What changes could I make to refactor the code to work faster?