When I was in college I met with a couple of Microsoft employees who interviewed me for an intern position with the Office team. In the interview they asked me to write something that would check if a word is a
palindrome or not. A palindrome is a word that can be spelled the same way forward and backward. I thought this was a great interview question and have since used it when I interview job candidates.
Can you come up with the solution? I'll post mine in the comments.
1 comment:
bool IsPalindrome(string word)
{
int half = word.Length / 2;
for(int i = 0; i < half; i++) {
char a = word[i];
char b = word[word.Length - 1 - i];
if(a != b)
return false;
}
return true;
}
Post a Comment