You are viewing a single comment's thread. Return to all 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"; }
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 →