Time Limit Exceeded. How i increase efficiency in this code


#1

public class Solution {

public int solve(String A) {
    Solution sol=new Solution();
    String D="";
    int q=0;
    for(int i=0;i<A.length();i++)
    {
        String B =A;
         D = sol.remchar(B,i);
        if(D.compareTo("true")==0)
    {
        q=1;
        break;
    }
    }

    if(q==1)
    {
        return 1;
    }
    else return 0;
}

public String remchar(String str,int p)
    {
        
       String X = str.substring(0, p) + str.substring(p + 1);
     
       StringBuffer sb = new StringBuffer();
       sb.append(X);
       StringBuffer Y =sb.reverse();
       
       if(String.valueOf(Y).compareTo(X)==0)
       {
        
           return "true";
       }
    else return "";
       
    }

}