For the following problem Palindrome I have using Recursion to solve it.
The code for the problem is
class Solution {
public:
bool checkp(string s,int l,int r){
if(l>=r){
return true;
}
if(s[l]!=s[r]){
return false;
}
return checkp(s,l+1,r-1);
}
bool isPalindrome(string s) {
string rm;
for(int i=0;i<s.length();i++){
if((s[i]>=65 && s[i]<=90)||(s[i]>=97 && s[i]<=122)){
rm+=tolower(s[i]);
}else if(s[i]>=48 && s[i]<=57){
rm+=s[i];
}
}
// cout<<rm<<"\n";
return checkp(rm,0,rm.length()-1);
}
};
Can anyone Please Explain Why I am Getting MLE.Not able to Understand.