Java Solution approach using StringBuilder

String str = A.toLowerCase().replace(" “, “”).replaceAll(”[^A-Za-z0-9]", “”);
StringBuilder str1 = new StringBuilder(str);
//System.out.println(str1);
StringBuilder str2 = new StringBuilder();

    for(int i = str1.length() - 1; i >= 0; i--){
        str2.append(str1.charAt(i));
    }

    //System.out.println(str2);

    return ((str1.toString().equals(str2.toString()))?1:0);
1 Like
Click here to start solving coding interview questions