You are viewing a single comment's thread. Return to all comments →
Java
public static String funnyString(String s) { // Write your code here int n = s.length(); boolean isFunny = true; for (int i = 0; i < n - 1; i++) { if (Math.abs(s.charAt(i+1) - s.charAt(i)) != Math.abs(s.charAt(n-i-2) - s.charAt(n-i-1))) { isFunny = false; break; } } return isFunny ? "Funny" : "Not Funny"; }
Seems like cookies are disabled on this browser, please enable them to open this website
Funny String
You are viewing a single comment's thread. Return to all comments →
Java