Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void UberIsPalindrome(string palindrome)
- {
- string isPalindrome1 = RemoveAllSpecialCharactersAndLower(palindrome);
- char[] isPalindrome2 = isPalindrome1.ToCharArray();
- Array.Reverse(isPalindrome2);
- Console.WriteLine((isPalindrome1 == string.Join("", isPalindrome2) ? true : false));
- }
- static string RemoveAllSpecialCharactersAndLower(string testStr)
- {
- string str = testStr.ToLower();
- char[] buffer = new char[str.Length];
- int indx = 0;
- foreach (char c in str)
- {
- if ((c >= '0' && c <= '9') || (c >= 'a' && c <= 'z'))
- {
- buffer[indx] = c;
- indx++;
- }
- }
- return new string(buffer, 0, indx);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement