diff --git a/August-LeetCoding-Challenge/03-Valid-Palindrome/Valid-Palindrome.cs b/August-LeetCoding-Challenge/03-Valid-Palindrome/Valid-Palindrome.cs new file mode 100644 index 0000000..01a12ba --- /dev/null +++ b/August-LeetCoding-Challenge/03-Valid-Palindrome/Valid-Palindrome.cs @@ -0,0 +1,20 @@ +public class Solution { + public bool IsPalindrome(string s) { + int begin = 0; + int end = s.Length-1; + while(begin <= end){ + while(begin<=end && !Char.IsLetterOrDigit(s[begin])){ + begin++; + } + while(begin<=end && !Char.IsLetterOrDigit(s[end])){ + end--; + } + if(begin<=end && Char.ToLower(s[begin]) != Char.ToLower(s[end])){ + return false; + } + begin++; + end--; + } + return true; + } +} diff --git a/README.md b/README.md index 49d7088..0c945c4 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,6 @@ https://leetcode.com - ## August LeetCoding Challenge Click [here](https://leetcode.com/explore/challenge/card/august-leetcoding-challenge/) for problem descriptions. @@ -10,6 +9,7 @@ Solutions in various programming languages are provided. Enjoy it. 1. [Detect Capital](https://github.com/AlgoStudyGroup/Leetcode/tree/master/August-LeetCoding-Challenge/01-Detect-Capital) 2. [Design HashSet](https://github.com/AlgoStudyGroup/Leetcode/tree/master/August-LeetCoding-Challenge/02-Design-HashSet) +3. [Valid Palindrome](https://github.com/AlgoStudyGroup/Leetcode/tree/master/August-LeetCoding-Challenge/03-Valid-Palindrome) ## July LeetCoding Challenge Click [here](https://leetcode.com/explore/featured/card/july-leetcoding-challenge/) for problem descriptions.