Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent df90bd6 commit b2fe516Copy full SHA for b2fe516
csharp/125-Valid-Palindrome.cs
@@ -0,0 +1,31 @@
1
+using System;
2
+namespace AlgoPractice
3
+{
4
+ public class Solution
5
+ {
6
+ public bool IsPalindrome(string s)
7
8
+ var left = 0;
9
+ var right = s.Length - 1;
10
+
11
+ while(left < right)
12
13
+ while (left < right && !char.IsLetterOrDigit(s[left])) left++;
14
+ while (left < right && !char.IsLetterOrDigit(s[right])) right--;
15
16
+ if (char.ToLower(s[left]) != char.ToLower(s[right]))
17
18
+ return false;
19
+ }
20
+ else
21
22
+ left++;
23
+ right--;
24
25
26
27
+ return true;
28
29
30
+}
31
0 commit comments