• + 1 comment

    You can just iterate over half of the string as we check the absolute values so the rest will be repetition.

    Java solution :

    private static boolean isFunny(String given) {
            int last = given.length() - 1;
            
            for (int first = 1; first <= given.length()/2; first++, last--) 	{
                if (Math.abs(given.charAt(first) - given.charAt(first - 1)) != Math.abs(given.charAt(last) - given.charAt(last - 1))) {
                    return false;
                }
            }
            
            return true;
    }