
/*
Online Java - IDE, Code Editor, Compiler

Online Java is a quick and easy tool that helps you to build, compile, test your programs online.
*/

public class Main
{
    
    public static void main(String[] args) {
        System.out.println("Welcome to Online IDE!! Happy Coding :)");
        isPalindrome("?aa?");
    }
    
    public static String isPalindrome(String str)
    {
        
        boolean specialCharFront=false;
        boolean specialCharBack=false;
        
        //Special characters need to be excluded from checking....
        //'\'   unable to process these in special characters since it recognises it as \
        
        Character [] special = new Character[] {',', '!', '@', '#', '$', '%', '^', '&', '*', '(', ')', '-', '_', '=', '+', '|', '[', ']', '{', '}', ';', ':', '/', '?', '.', '>'};
        
        // this will force the string to get shorter
        
        while (str.length()>1)
        {
            
            
        if (str.charAt(0)==str.charAt(str.length()-1))
        {
            
            System.out.println("First char: " + str.charAt(0));
            System.out.println("Last char: " + str.charAt(str.length()-1));
            
            
            for (int j=0; j<special.length; j++)
            {
                if (str.charAt(0)==special[j])
                {
                    specialCharFront=true;
                     //return isPalindrome(str.substring(1,( str.length()-1)));
                }
                
                 if (str.charAt(str.length()-1)==special[j])
                {
                    specialCharBack=true;
                     //return isPalindrome(str.substring(1,( str.length()-1)));
                }
            }
            
            if(specialCharFront && specialCharBack)
            {
                return isPalindrome(str.substring(1,( str.length()-1)));
                
            }
            
            
            
            return isPalindrome(str.substring(1,( str.length()-1)));
        }
    
        else
        {
            return "false";
        }
        }
        return "";
        
    }
    
}
            
            