Help me in solving BLAST3 problem.Actually ,I am getting TLE ,how i can optimise it

My issue

My code

#include <iostream>
using namespace std;
bool is_palin(string& s, int start, int end) {
    while (start < end) {
        if (s[start] != s[end])
            return false;
        start++;
        end--;
    }
    return true;
}
bool solve(int i,string &s){
    if(i>=s.size()) return false;
    if(is_palin(s,0,s.size()-1)) return true;
    bool no=solve(i+1,s);
    string str;
    for(int j=0;j<s.size();j++){
        if(j==i||j==i-1||j==i+1) continue;
        str.push_back(s[j]);
    }
    bool yes=solve(1,str);
    return no||yes;
}


int main() {
	int t; cin>>t;
	while(t--){
	    int n; cin>>n;
	    string s; cin>>s;
	    unordered_map<int,string>
	    if(solve(1,s)) cout<<"YES"<<endl;
	    else{
	       cout<<"NO"<<endl;
	   }
	}
	return 0;
}

Problem Link: BLAST3 Problem - CodeChef

@supriyakumari8
the recursive solution will always gives u tle bcozz of high constraints.
so think of it as like if the size of string%3==1 u can always make it a palindrome of size 1 and else u have to do some stuffs so there are not many cases like i give u one hint if somehow i can make the starting and the ending of the string with same character i can always make it as a palindrome .