A palindrome is a word that reads the same backward and forw
Solution
import java.util.*;
 public class expectopallendrome {
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        System.out.println(\"enter string to check pallendrom:\");
        String input=sc.next();
        String copys=\"\";
        String rev=\"\";
        int len=0;
        char k=\'s\';
        int count=0;
        int cont2=0;
        int fcount=0;
        int fcont2=0;
        for(int i=input.length()-1;i>=0;i--)
        rev=rev+input.charAt(i);
    if(input.equalsIgnoreCase(rev)){
        len=rev.length();
    System.out.println(len);}
    else
    {
        for(int i=0;i<input.length();i++){
            if(input.charAt(i)!=k){
                k=input.charAt(i);
            count++;}
            else{
                cont2++;
            copys=copys+input.charAt(i);}
              
        }
    fcount=count-1;
        fcont2=cont2+1;
          
        System.out.println(fcont2+fcount+fcont2);
   
      
    }
 
 output:
 enter string to check pallendrom:
 baaa
 7
 
 }
}

