• + 0 comments
    public static String funnyString(String s) {
        
            StringBuilder build = new StringBuilder(s);
            String revStr = build.reverse().toString();
            
            int n = s.length();
            char[] firstStr = s.toCharArray();
            char[] secondStr = revStr.toCharArray();
            
            for(int i=0; i<n-1; i++){
                
                int diff1 = Math.abs((int)firstStr[i] - (int)firstStr[i+1]);
                int diff2 = Math.abs((int)secondStr[i] - (int)secondStr[i+1]);
                
                if(diff1 != diff2){
                    return "Not Funny";
                }
                
            }
            return "Funny";
    
        }