54
1
// This is a solution to a question that was asked as part of:
2
// https://www.devleader.ca/2023/09/02/tons-of-beginner-resources-dev-leader-weekly-7/
3
4
using System;
5
6
bool IsPalindrome(string input)
7
{
8
if (string.IsNullOrWhiteSpace(input))
9
{
10
return false;
11
}
12
13
// Create a Span from the input string
14
var inputSpan = input.AsSpan();
15
16
// Pointers to the start and end of the span
17
int left = 0, right = inputSpan.Length - 1;
18
19
while (left < right)
20
{
21
// Skip non-alphanumeric characters from the left
22
while (left < right && !char.IsLetterOrDigit(inputSpan[left]))
23
left++;
24
Cached Result