Showing posts with label Valid Palindrome. Show all posts
Showing posts with label Valid Palindrome. Show all posts
LeetCode: Valid Palindrome
Unknown
Problem:
https://leetcode.com/problems/valid-palindrome/class Solution { public: bool isPalindrome(string s) { int n=s.length(),f=1; string temp=""; for(int i=0;i<n;i++) { if(isalpha(s[i])||isdigit(s[i])) temp+=tolower(s[i]); } int len=temp.length(); for(int i=0;i<len/2;i++) { if(temp[i]!=temp[len-i-1]) { return false; } } return true; } };
02:41
Leet Code
,
Valid Palindrome
Subscribe to:
Posts
(
Atom
)