You are viewing a single comment's thread. Return to all comments →
Can be done without reverse
int length = s.length(); int left = 0; int right = length - 1; boolean funny = true; while (left < length - 1 && right > 0) { if (Math.abs(((int) s.charAt(left + 1) - (int) s.charAt(left))) != Math .abs(((int) s.charAt(right - 1) - (int) s.charAt(right)))) { funny = false; break; } left++; right--; } System.out.println((left == length - 1 && right == 0 && funny) ? "Funny" : "Not Funny");
Funny String
You are viewing a single comment's thread. Return to all comments →
Can be done without reverse